Difference between revisions of "CSC270 Final Exam 2016"

From dftwiki3
Jump to: navigation, search
(Expected Output)
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 10:09, 16 April 2016 (EDT)
 
--[[User:Thiebaut|D. Thiebaut]] ([[User talk:Thiebaut|talk]]) 10:09, 16 April 2016 (EDT)
  
<onlydft>
+
 
 
<br /><br /><br />
 
<br /><br /><br />
 
<bluebox>
 
<bluebox>
Line 8: Line 8:
 
All work has to be done individually.
 
All work has to be done individually.
 
<br />
 
<br />
Any reference you use should be cited (this include class material).
+
Any reference you use should be cited (this includes class material).
 +
<br />
 +
All problems are worth the same amount of points.
 +
<br />
 +
You cannot discuss the details of this exam with anyone except your instructor.  No question will be answered in person after you receive the exam.  '''No debugging help will be available'''.  If you have questions regarding the exam, you should  post them confidentially on Piazza, visible to your instructor only.  If the question is found not to reveal any information that could be used as solution, it will be shared with the class, along with the answer. 
 
<br />
 
<br />
You cannot discuss the details of this exam with anyone except your instructor.  No question will be answered in person after you receive the exam.  '''No debugging help will be available'''.  If you have questions regarding the exam, you should email them to your instructor.  The exam is given under the rules of the [http://www.smith.edu/sao/handbook/socialconduct/honorcode.php Smith College Honor Code].
+
The exam is given under the rules of the [http://www.smith.edu/sao/handbook/socialconduct/honorcode.php Smith College Honor Code].
You have 1 week to work on this exam, and you may start at any point in time by requesting the exam from your instructor by email (Please do not expect answers between 9 p.m. and 7 a.m.)   Make an appointment with your instructor to demonstrate your design, no later than 1 week after the exam was emailed to you.  The last possible date to submit and demonstrate your project is the official last day of exams, Friday 5/6/16, at 4:00 p.m.
+
You have until the last day of exams at 4:00 p.m. to submit your files to Moodle.  Make an appointment with your instructor to demonstrate your design (or film your demonstration).  The last possible date to submit and demonstrate your project is the official last day of exams, Friday 5/6/16, at 4:00 p.m.
 
</bluebox>
 
</bluebox>
 
<br />
 
<br />
 
<br />
 
<br />
 +
=Problem 0=
 +
<br />
 +
What is the maximum frequency at which the Arduino can activate one of its digital '''output''' pins (not the PWM pins).  Explain how you get your answer.
 
<br />
 
<br />
 
=Problem 1=
 
=Problem 1=
 
<br />
 
<br />
The program below implements a list of pairs of ints.  A linked list is first created using ints from an array, and then the list is displayed, highlighting the pairs.
+
The program below implements a linked-list of pairs of ints.  Study it, run it, play with it, and make sure you are comfortable with the code.
 
<br />
 
<br />
 
::<source lang="C" highlight="40,41">
 
::<source lang="C" highlight="40,41">
Line 77: Line 84:
 
</source>
 
</source>
 
<br />
 
<br />
The program above creates a linked list and displays it.  The list list is composed of numbers found in an array of '''ints'''.  The program can use 3 different arrays of ints, defined at '''table1''', '''table2''', and '''table3'''.  In its implementation above, it uses table1.  If you wanted to use table2 instead, you could change the highlighted lines as illustrated below:
+
As you should have observed, the program creates a linked list and then displays it.  The list list is composed of numbers originally found in an array of '''ints'''.  The program can use 3 different arrays of ints, defined at '''table1''', '''table2''', and '''table3'''.  In its implementation above, it uses table1.  If you wanted to use table2 instead, you could change the highlighted lines as illustrated below:
 
<br />
 
<br />
 
::<source lang="C">
 
::<source lang="C">
Line 84: Line 91:
 
</source>
 
</source>
 
<br />
 
<br />
* Compile and run the program, and verify that it displays the list of pairs.  Make sure you understand how it works.
+
* (I will test your program with all 3 arrays.)
 +
* Compile and run the program for all 3 arrays, and verify that it correctly displays the list of pairs.   
 
<br />
 
<br />
 
==Your Assignment==
 
==Your Assignment==
Line 105: Line 113:
 
==Expected Output==
 
==Expected Output==
 
<br />
 
<br />
Your program should output the original linked list, followed by the list with the "bad" pairs removed.
+
Your program should output the original linked list.
 
<br />
 
<br />
 
<br />
 
<br />
Line 116: Line 124:
 
</source>
 
</source>
 
<br />
 
<br />
 +
 
==Submission==
 
==Submission==
 
<br />
 
<br />
Line 191: Line 200:
 
<br />
 
<br />
  
</onlydft>
+
 
 
<br />
 
<br />
 
<br />
 
<br />

Latest revision as of 14:29, 28 April 2016

--D. Thiebaut (talk) 10:09, 16 April 2016 (EDT)





This final exam is take-home. It is open-books, open-notes, and open-Web. It is due a week after it is made available to you.
All work has to be done individually.
Any reference you use should be cited (this includes class material).
All problems are worth the same amount of points.
You cannot discuss the details of this exam with anyone except your instructor. No question will be answered in person after you receive the exam. No debugging help will be available. If you have questions regarding the exam, you should post them confidentially on Piazza, visible to your instructor only. If the question is found not to reveal any information that could be used as solution, it will be shared with the class, along with the answer.
The exam is given under the rules of the Smith College Honor Code. You have until the last day of exams at 4:00 p.m. to submit your files to Moodle. Make an appointment with your instructor to demonstrate your design (or film your demonstration). The last possible date to submit and demonstrate your project is the official last day of exams, Friday 5/6/16, at 4:00 p.m.



Problem 0


What is the maximum frequency at which the Arduino can activate one of its digital output pins (not the PWM pins). Explain how you get your answer.

Problem 1


The program below implements a linked-list of pairs of ints. Study it, run it, play with it, and make sure you are comfortable with the code.

#include <stdio.h>
#include <stdlib.h>

int table1[] = { 1, 10, 2, 20, 5, 15, 7, 35, 11, 9 };
int N1       = 10;
int table2[] = { 10, 1, 20, 2, 50, 15, 35, 7, 11, 9, 22, 21 };
int N2       = 12;
int table3[] = { };
int N3       = 0;


typedef struct node {
  int  item1;
  int  item2;
  struct node *next;
} Node;

Node* addNode( int x, int y, Node* List ) {
  Node *p = (Node *) malloc( sizeof( Node ) );
  p->item1 = x;
  p->item2 = y;
  p->next = List;
  return p;
}

void display( Node* List ) {
  Node *p = List;
  printf( "List = " );
  while (  p!= NULL ) {
    printf( "(%d, %d) ", p->item1, p->item2 );
    p = p->next;
  }
  printf( "\n\n" );
}


int main() {
  Node *List = NULL;
  //--- define an array (equal to table1, or table2, or table3)---
  int*  table = table1;  // array
  int   N     = N1;      // dimension of array


  //--- create a linked-list of pairs of ints taken ---
  //--- from table.                                 ---
  for ( int i=0; i<N; i += 2 ) 
    List = addNode( table[i], table[i+1], List );
  
  //--- display the list ---
  display( List );

  return 0;
}


As you should have observed, the program creates a linked list and then displays it. The list list is composed of numbers originally found in an array of ints. The program can use 3 different arrays of ints, defined at table1, table2, and table3. In its implementation above, it uses table1. If you wanted to use table2 instead, you could change the highlighted lines as illustrated below:

  int*  table = table2;  // array                                                                                   
  int   N     = N2;      // dimension of array


  • (I will test your program with all 3 arrays.)
  • Compile and run the program for all 3 arrays, and verify that it correctly displays the list of pairs.


Your Assignment


Add a function called removePair() to the program. This function will remove all pairs/nodes from the linked list where the first element of the pair is larger than the second element of the pair. For example, if the list is initially displayed as

List = (11, 9) (7, 35) (5, 15) (2, 20) (1, 10)


Then after calling the function removePair(), the list should display as:

List =  (7, 35) (5, 15) (2, 20) (1, 10)


RemovePair() will have removed (11, 9) from the list since 11 is larger than 9.
If several pairs exist that have the first item larger than the second one, then removePair() will remove all of them.

Expected Output


Your program should output the original linked list.

Example:

List = (11, 9) (7, 35) (5, 15) (2, 20) (1, 10) 
List = (7, 35) (5, 15) (2, 20) (1, 10)


Submission


  • Submit a text file (not pdf, not RTF, not doc, or docx, just plain ASCII) to Moodle, in the Final Exam, Problem 1 section.



Problem 2


Your Assignment


  1. Program the 6811 to generate an output signal that can be made to oscillate at 3 different frequencies. To switch frequency, you will simply stop the 6811, enter a different program (or constants) in memory, and restart it. You are free to pick the 3 different frequencies that best fit your design.
  2. Connect the output signal of the 6811 to an Arduino that has 3 signals connected to 3 different LEDs.
  3. Program the Arduino to recognize the different frequencies. When the Arduino recognizes the slowest of the 3 frequencies, it activates one LED. When it recognizes the fastest frequency, it activates another LED. Finally, it activates the last of the 3 LEDs when it recognizes the medium-range frequency.
  4. All LEDs should be off when the 6811 is not activating its output signal. For example, assume that you have picked 1Hz, 10Hz and 100Hz as your 3 frequencies. Your Arduino is connected to 3 LEDs, one green, one yellow, and one red. When the 6811 is not running your program, all LEDs are OFF. When the 6811 generates a 1Hz output, the Arduino will activate the green LED, which will stay ON as long as the 1 Hz signal is active. When you stop the 6811 program, the green LED will automatically turn OFF. All LEDs will be OFF. When you program the 6811 to generate a 10Hz signal, the Arduino will measure this signal and activate the yellow LED, which will stay ON as long as the 10Hz signal is active. And similarly for the 100Hz and red LED.
  5. Demonstrate the correct behavior of your setup to your instructor for credit. If your instructor is not around, take a detailed movie of your experiment, with explanations of what happens.


Submission


  • Write up a lab report of your setup, including the diagrams of your hardware setup, and the code (assembly and C).
  • Submit the lab report to Moodle, in the Final Exam Problem 2 section.



Scheduling Lab Time


There are only 7 6811 Kits available, so you will need to schedule 4-hour blocks ahead of time. You are not allowed to reserve two consecutive 4-hour blocks, unless there are fewer than 7 students left working on their exam. If you haven't finished your design at the end of a 4-hour block, you must remove all the wires and chips and put the kit back in the cabinet. You'll have to rewire your kit when you start a new 4-hour block.
Use this Doodle page to reserve a 4-hour block. Only 1 block at a time, please!
http://doodle.com/poll/ptpy8sgdkuisp8pp