CS32 Final Exam. E03, S15, Phill Conrad, UC Santa Barbara Tuesday, 06/08/2015, 8am 11am
|
|
- Britney Martin
- 5 years ago
- Views:
Transcription
1 1 CS32 Final Exam E03, S15, Phill Conrad, UC Santa Barbara Tuesday, 06/08/2015, 8am 11am Please write your name above AND AT THE TOP OF EVERY PAGE Be sure you turn in every page of this exam. This exam is closed book, closed notes, closed mouth, cell phone off You are permitted one sheet of paper (max size 8.5x11") on which to write notes These sheets will be collected with the exam, and might not be returned Please write your name on your notes sheet READ THIS NOW: SERIOUSLY! Some of this exam will test what you have learned in familiar situations, while other parts will test your ability to apply what you leave learned in new situations. In particular, during the last lecture of the quarter, I briefly discussed QuickSort. I strongly hinted that while I would NOT ask you to recall specific details of QuickSort on the exam, I might very possibly give you an outline of QuickSort on the final exam, and then ask you to apply what you already know in light of this new information. So, this should not come as a surprise: the handout you got with this exam contains an outline of quicksort. Most of the questions on this exam pertain to quicksort in one way or another. 1. The first case study involves quicksort in the context of arrays. On one side of your handout, please find a listing of quicksort.hand review the function prototypes listed there. You will be asked to write portions of the code for some of these functions, so I encourage you to take a moment to get familiar with the "big picture" of this code before starting. 2. The second case study involves applying the ideas of quicksort to sorting linked lists. On the other side of your handout, please find a listing for the class LinkedList. Note that LinkedListhas a member function called sort. It also has function prototypes for the big three, and two private helper functions that will be used in both the big three, and in our implementation of quicksort for linked lists. When you get to those questions, take a few moments to look over that side of the handout. Ok! Let's get started!
2 2 1. (4 pts) Please refer to the handout with information about QuickSort. First, read through the material in the left column. Then look at the function prototypes in the right hand column. Find the function prototype for issorted. This function takes an array of size n and determines whether it is sorted or not. It is used as a helpful function in QuickSort. As you may recall from mergesort, the recursion can stops when the array is of size 0 or 1, since an array of size 0 or 1 is already "sorted". We can do better: if any size subarray is already sorted, we can avoid the work of all the recursive calls, and speed things up. The code for issorted is partially complete below. Please add only the missing lines to complete the code so that it works correctly, and runs in time O(n). NOTE: This code is tested, and works correctly on arrays of size 0, 1 and sizes greater than 1. You should be able to make it work by ONLY adding a correct condition in the if test. FOR FULL CREDIT, DO NOT ADD ANY OTHER CODE. Work within the framework given here. bool issorted(int *a, int n) { for (int i=0; i<n-1; i++) { if ( ) { return false; return true;
3 3 2. (4 pts) Another helper function we'll use in building quicksort is a function that counts the number of occurences of an item in an array. We use this to count how many times the pivot element occurs. Here, ais an array of size nand xis the value that we are counting occurences of. Fill in the body of the function numoccurencesbelow: int numoccurences(int *a, int n, int x) { int count=0; return count; // number of times value x occurs in array a
4 4 3. (4 pts) Yet another helper function we'll use in building quicksort is one that pulls out the elements smaller than the pivot into a separate array. This function has the prototype: int copylessthanpivot(int *a, int n, int pivot, int *dest); Here, ais the array we are copying from. The array ais of size n. The value pivotis the number we are comparing each element of awith, and destis an array that we are copying the new values into.. The return value is the number of elements copied into dest. int left[n]; int right[n]; int numleft = copylessthanpivot(a,n,pivot,left); int numright = copygreaterthanpivot(a,n,pivot,right); The code at right from our quicksort implementation shows how it is used, along with its companion function copygreaterthanpivot. We see that after calling copylessthanpivot, the valuiable numleftwill contain a count of the number of elements of the array athat were smaller than the value pivot, and the array leftwill contain those values in elements left[0]through left[numleft-1]. Fill in the two lines of code in copylessthanpivot. There are EXACTLY two missing lines of code. (Note that it is possible to combine them into one, but please don't do that.) Also note that copygreaterthanpivotwill be exactly the same except that it will have a > instead of a < symbol in the if test. int copylessthanpivot(int *a, int n, int pivot, int *dest) { int count=0; for (int i=0; i<n; i++) { if (a[i] < pivot) { return count;
5 5 4. (9 pts) Now quicksort is easy to build. The full implementation appears on page 12 of this exam, which you may want to refer to when answering this question, along with the outline on the handout. However, we still haven't written the code for the reassemblehelper function. An incomplete version of that function appears below. Fill in the missing three lines. Each blank gets exactly one assignment statement. void reassemble(int *a, int n, int *left, int nleft, int pivot, int pivotcount, int *right, int nright) { if (nleft+pivotcount+nright!= n) { throw std::invalid_argument("nleft + pivotcount + nright should sum t for (int i=0;i<nleft;i++) { for (int i=nleft; i<nleft+pivotcount; i++) { for (int i=0; i<nright; i++) { And with that, our implementation of quicksort is complete.
6 6 5. Now, before we move on to applying quicksort to linked lists, a half time feature: questions about operating systems and tools. a. (3 pts) Briefly: What is the purpose of an operating system? Answer in 8 words or fewer. b. (3 pts) Briefly: In the context of an operating system, what is a process? c. (3 pts) Briefly: In the context of Unix, what is a system call? d. (3 pts) Briefly: What is a memory leak? e. (3 pts) Briefly: What tool can help you locate a memory leak? f. (3 pts) Briefly: If you want to use gdb to debug a program, what should you add to CXXFLAGS in your Makefile?
7 7 6. We now turn our attention to the class LinkedListon the other side of the handout that came with your exam. Please first note that the member function addatheadand addattailadd elements to the list. Please fill in the missing lines of code in these functions below as they would appear in the linkedlist.cppfile: a. (4 pts) Fill in exactly ONE missing line of code in addathead: void LinkedList::addAtHead(int data) { Node *n = new Node; n->data = data; this->head = n; if (this->tail==null) this->tail = n; b. (8 pts) Fill in exactly TWO missing lines of code in addattail: void LinkedList::addAtTail(int data) { Node *n = new Node; n->data = data; n->next = NULL; if (this->tail==null) else { this->tail = n;
8 8 7. The big three are implemented using helper functions recycleallmemoryand addaddattail, as shown here: LinkedList & LinkedList::operator= (const LinkedList &right) { if (this!= &right) { recycleallmemory(); addallattail(right); return (*this); LinkedList::~LinkedList() { recycleallmemory(); LinkedList::LinkedList(const LinkedList &orig) { this->head=null; this->tail=null; this->addallattail(orig); Your job, of course, is to finish the implementations of these two functions. They are shown, in incomplete form, on the following page. Finish them, as indicated. a. (8 pts) Fill in the two blanks in addallattail void LinkedList::addAllAtTail(const LinkedList &orig) { for (Node *n= ; n!=null; n=n->next) { continued on the next page...
9 9...continued from previous page b. (8 pts) Fill in the two missing lines in recycleallmemory void LinkedList::recycleAllMemory() { Node *p = while (p!=null) { Node *d = p; p=p->next; this->head = NULL; this->tail = NULL; 8. (8 pts) Just as with the quicksort on an array, we will need a way of determining when a list is sorted. Please finish the following function which determines whether a list is already sorted. Be sure that it can run in time O(n), where n is the size of the list. Note that a list of size 0 is already sorted, as is a list of size 1. Be sure you function handles those cases, and does NOT segfault! FOR FULL CREDIT: Confine your answer to filling in only a single line of code in the first blank, and filling in the condition of the for loop. There may be other ways of solving it, but there is a way to solve it in this form, and for full credit, you need to come up with it. bool LinkedList::isSorted() { if (this->head == NULL) for (Node *n=this->head; ; n=n->next) { if (n->next->data < n->data) return false; return true;
10 10 9. (9 pts) Now, we should be able to use the helper functions already written to put together a quicksort for a linked list. Fill in the missing pieces. void LinkedList::sort() { if (this->issorted()) { return; int pivot = this->head->data; LinkedList left; LinkedList middle; LinkedList right; for (Node *p=this->head; p!=null; p=p->next) { if (p->data < pivot) { left.addattail(p->data); else if (p->data == pivot) { middle.addattail(p->data); else { right.addattail(p->data); left.sort(); right.sort(); // FILL IN THE PARAMETERS this->recycleallmemory(); this->addallattail( ); this->addallattail( ); this->addallattail( );
11 (4 pts) In the implementation of LinkedList::sort, we find this line of code: int pivot = this->head->data; Suppose your pair partner were concerned that this->head->datamight produce a segmentation fault due to this->headbeing a null pointer. Write a short, but convincing arrgument (based on the implementation of the functions you have given on this exam) to reassure your pair that this cannot happen. 11. In the member function LinkedList::sort, we see that left,middle,and rightare declared as local variables. a. (3 pts) Will they be stored on the stack or the heap? b. (3 pts) What about the Nodestructs that make up the linked lists that headtail inside each of left,middle,and right: are these on the heap or the stack? 12. For a LinkedListobject representing a list of size n: a. (3 pts) What is the best case running time for the member function sortin terms of big O notation? NOTE: I said best case, not worst case. Be careful! b. (3 pts) Explain your answer to the previous question.
12 12 The final implementation of quicksort for questions 1 through 4 (on pages 2 through 5): void quicksort(int *a, int n) { if (issorted(a,n)) return; int pivot=a[0]; int pivotcount = numoccurences(a,n,pivot); int left[n]; int right[n]; int numleft = copylessthanpivot(a,n,pivot,left); int numright = copygreaterthanpivot(a,n,pivot,right); quicksort(left,numleft); quicksort(right,numright); // copy back into a: all elements from left, // then pivotcount copies of pivot, // then all elements from right reassemble(a,n,left,numleft,pivot,pivotcount,right,numright); End of Exam total points=100
CS32 Final Exam. E03, F15, Phill Conrad, UC Santa Barbara
1 #1 Page: 1 Name: CS32 Final E03, F15, Phill Conrad, UC Santa Barbara Thursday, 12/10/2015, noon 3pm Name: Umail Address: @ umail.ucsb.edu Please write your name above AND AT THE TOP OF EVERY PAGE Be
More informationCS16 Final Exam E03, 10S, Phill Conrad, UC Santa Barbara Wednesday, 06/09/2010
CS16 Final Exam E03, 10S, Phill Conrad, UC Santa Barbara Wednesday, 06/09/2010 Name: Umail Address: @ umail.ucsb.edu Circle Lab section: 9AM 10AM 11AM Noon Link to Printer Friendly PDF Version Please write
More informationCS16 Midterm Exam 2 E02, 09F, Phill Conrad, UC Santa Barbara Wednesday, 11/18/2009
CS16 Midterm Exam 2 E02, 09F, Phill Conrad, UC Santa Barbara Wednesday, 11/18/2009 Name: Umail Address: @ umail.ucsb.edu Circle Lab section: 8AM 10AM 11AM noon Link to Printer Friendly PDF Version Answer
More information***PRACTICE EXAM 02 for*** CS16 Midterm Exam 2 E02, 09F, Phill Conrad, UC Santa Barbara Actual exam scheduled for: 11/18/2009
***PRACTICE EXAM 02 for*** CS16 Midterm Exam 2 E02, 09F, Phill Conrad, UC Santa Barbara Actual exam scheduled for: 11/18/2009 Name: Umail Address: @ umail.ucsb.edu Circle Lab section: 8AM 10AM 11AM noon
More informationCS32 Midterm Exam E01, F15, Phill Conrad, UC Santa Barbara Wednesday, 10/28/2015, 11am 12:15pm
1 CS32 Midterm Exam E01, F15, Phill Conrad, UC Santa Barbara Wednesday, 10/28/2015, 11am 12:15pm Please write your name above AND AT THE TOP OF EVERY PAGE Be sure you turn in every page of this exam. "End
More informationCS56 Midterm Exam. E01, W16, Phill Conrad, UC Santa Barbara Wednesday, 02/10/2015
1 Page: 1 Name: CS56 Midterm Exam E01, W16, Phill Conrad, UC Santa Barbara Wednesday, 02/10/2015 Name: Umail Address: @ umail.ucsb.edu Please write your name above AND AT THE TOP OF EVERY PAGE Please put
More informationCSCI 102L - Data Structures Midterm Exam #2 Spring 2011
CSCI 102L - Data Structures Midterm Exam #2 Spring 2011 (12:30pm - 1:50pm, Thursday, March 24) Instructor: Bill Cheng ( This exam is closed book, closed notes, closed everything. No cheat sheet allowed.
More information#101 Page: 1 Name: CS32 Midterm Exam. E01, W15, Phill Conrad, UC Santa Barbara
1 # Page: 1 Name: CS32 Midterm E01, W15, Phill Conrad, UC Santa Barbara Wednesday, 04/30/2015, 9:30am 10:45am Name: Umail Address: @ umail.ucsb.edu Please write your name above AND AT THE TOP OF EVERY
More informationCS16 Midterm Exam 2 E02, 10W, Phill Conrad, UC Santa Barbara Tuesday, 03/02/2010
CS16 Midterm Exam 2 E02, 10W, Phill Conrad, UC Santa Barbara Tuesday, 03/02/2010 Name: Umail Address: @ umail.ucsb.edu Circle Lab section: 3PM 4PM 5PM Link to Printer Friendly PDF Version Please write
More informationCS8 Final Exam E03, 09M, Phill Conrad, UC Santa Barbara 09/10/2009
CS8 Final Exam E03, 09M, Phill Conrad, UC Santa Barbara 09/10/2009 Name: Umail Address: @ umail.ucsb.edu Please write your name only on this page. That allows me to grade your exams without knowing whose
More informationCS 61B Summer 2005 (Porter) Midterm 2 July 21, SOLUTIONS. Do not open until told to begin
CS 61B Summer 2005 (Porter) Midterm 2 July 21, 2005 - SOLUTIONS Do not open until told to begin This exam is CLOSED BOOK, but you may use 1 letter-sized page of notes that you have created. Problem 0:
More informationCS16 Midterm Exam 1 E01, 10S, Phill Conrad, UC Santa Barbara Wednesday, 04/21/2010, 1pm-1:50pm
CS16 Midterm Exam 1 E01, 10S, Phill Conrad, UC Santa Barbara Wednesday, 04/21/2010, 1pm-1:50pm Name: Umail Address: @ umail.ucsb.edu Circle Lab section: 9am 10am 11am noon (Link to Printer Friendly-PDF
More informationMidterm II Exam Principles of Imperative Computation Frank Pfenning. March 31, 2011
Midterm II Exam 15-122 Principles of Imperative Computation Frank Pfenning March 31, 2011 Name: Sample Solution Andrew ID: fp Section: Instructions This exam is closed-book with one sheet of notes permitted.
More informationCPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001
CPSC 211, Sections 201 203: Data Structures and Implementations, Honors Final Exam May 4, 2001 Name: Section: Instructions: 1. This is a closed book exam. Do not use any notes or books. Do not confer with
More informationE02, W16, Phill Conrad, UC Santa Barbara
1 Page: 1 Name: CS56 Midterm Exam E02, W16, Phill Conrad, UC Santa Barbara Monday, 02/29/2016 Name: Umail Address: @ umail.ucsb.edu Please write your name above AND AT THE TOP OF EVERY PAGE Please put
More informationCS171 Final Practice Exam
CS171 Final Practice Exam Name: You are to honor the Emory Honor Code. This is a closed-book and closed-notes exam. You have 150 minutes to complete this exam. Read each problem carefully, and review your
More informationCOS 226 Midterm Exam, Spring 2009
NAME: login ID: precept: COS 226 Midterm Exam, Spring 2009 This test is 10 questions, weighted as indicated. The exam is closed book, except that you are allowed to use a one page cheatsheet. No calculators
More informationCS171 Midterm Exam. October 29, Name:
CS171 Midterm Exam October 29, 2012 Name: You are to honor the Emory Honor Code. This is a closed-book and closed-notes exam. You have 50 minutes to complete this exam. Read each problem carefully, and
More informationExam I Principles of Imperative Computation, Summer 2011 William Lovas. May 27, 2011
Exam I 15-122 Principles of Imperative Computation, Summer 2011 William Lovas May 27, 2011 Name: Sample Solution Andrew ID: wlovas Instructions This exam is closed-book with one sheet of notes permitted.
More informationCS171 Final Practice Exam
CS171 Final Practice Exam Name: You are to honor the Emory Honor Code. This is a closed-book and closed-notes exam. You have 150 minutes to complete this exam. Read each problem carefully, and review your
More informationSorting. Sorting in Arrays. SelectionSort. SelectionSort. Binary search works great, but how do we create a sorted array in the first place?
Sorting Binary search works great, but how do we create a sorted array in the first place? Sorting in Arrays Sorting algorithms: Selection sort: O(n 2 ) time Merge sort: O(nlog 2 (n)) time Quicksort: O(n
More informationCSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)
Name: Email address: Quiz Section: CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will
More informationCS 137 Part 8. Merge Sort, Quick Sort, Binary Search. November 20th, 2017
CS 137 Part 8 Merge Sort, Quick Sort, Binary Search November 20th, 2017 This Week We re going to see two more complicated sorting algorithms that will be our first introduction to O(n log n) sorting algorithms.
More informationCSE373 Fall 2013, Midterm Examination October 18, 2013
CSE373 Fall 2013, Midterm Examination October 18, 2013 Please do not turn the page until the bell rings. Rules: The exam is closed-book, closed-note, closed calculator, closed electronics. Please stop
More informationCS106X Handout 35 Winter 2018 March 12 th, 2018 CS106X Midterm Examination
CS106X Handout 35 Winter 2018 March 12 th, 2018 CS106X Midterm Examination This is an open-book, open-note, closed-electronic-device exam. You needn t write #includes, and you may (and you re even encouraged
More informationUniversity of Illinois at Urbana-Champaign Department of Computer Science. First Examination
University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Spring 2007 7p-9p, Thursday, March 1 Name: NetID: Lab Section
More informationCS56 final (E03) W15, Phill Conrad, UC Santa Barbara Wednesday, 03/18/2015. Name: Umail umail.ucsb.edu. Circle one: 4pm 5pm 6pm
CS56 final (E03) W15, Phill Conrad, UC Santa Barbara Wednesday, 03/18/2015 Name: Umail Address: @ umail.ucsb.edu Circle one: 4pm 5pm 6pm Please write your name only on this page. That allows me to grade
More informationPart I: Short Answer (12 questions, 65 points total)
CSE 143 Sp01 Final Exam Sample Solution page 1 of 14 Part I: Short Answer (12 questions, 65 points total) Answer all of the following questions. READ EACH QUESTION CAREFULLY. Answer each question in the
More informationFinal: CSS 342 SAMPLE. Data Structures, Algorithms, and Discrete Mathematics I
Final: CSS 342 SAMPLE Data Structures, Algorithms, and Discrete Mathematics I This is a closed-book, closed-notes exam, except for a single sheet of letter-sized, double-sided hand-written notes. Total
More informationCS125 : Introduction to Computer Science. Lecture Notes #38 and #39 Quicksort. c 2005, 2003, 2002, 2000 Jason Zych
CS125 : Introduction to Computer Science Lecture Notes #38 and #39 Quicksort c 2005, 2003, 2002, 2000 Jason Zych 1 Lectures 38 and 39 : Quicksort Quicksort is the best sorting algorithm known which is
More informationUniversity of Illinois at Urbana-Champaign Department of Computer Science. Final Examination
University of Illinois at Urbana-Champaign Department of Computer Science Final Examination CS 225 Data Structures and Software Principles Spring 2010 7-10p, Wednesday, May 12 Name: NetID: Lab Section
More informationSorting Algorithms. + Analysis of the Sorting Algorithms
Sorting Algorithms + Analysis of the Sorting Algorithms Insertion Sort What if first k elements of array are already sorted? 4, 7, 12, 5, 19, 16 We can shift the tail of the sorted elements list down and
More informationCommon Misunderstandings from Exam 1 Material
Common Misunderstandings from Exam 1 Material Kyle Dewey Stack and Heap Allocation with Pointers char c = c ; char* p1 = malloc(sizeof(char)); char** p2 = &p1; Where is c allocated? Where is p1 itself
More informationCS134 Spring 2005 Final Exam Mon. June. 20, 2005 Signature: Question # Out Of Marks Marker Total
CS134 Spring 2005 Final Exam Mon. June. 20, 2005 Please check your tutorial (TUT) section from the list below: TUT 101: F 11:30, MC 4042 TUT 102: M 10:30, MC 4042 TUT 103: M 11:30, MC 4058 TUT 104: F 10:30,
More informationCSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)
Name: Email address: Quiz Section: CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will
More informationUniversity of Illinois at Urbana-Champaign Department of Computer Science. First Examination
University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Spring 2007 7p-9p, Thursday, March 1 Name: NetID: Lab Section
More informationLecture Notes on Memory Layout
Lecture Notes on Memory Layout 15-122: Principles of Imperative Computation Frank Pfenning André Platzer Lecture 11 1 Introduction In order to understand how programs work, we can consider the functions,
More informationName: Username: I. 20. Section: II. p p p III. p p p p Total 100. CMSC 202 Section 06 Fall 2015
CMSC 202 Section 06 Fall 2015 Computer Science II Midterm Exam I Name: Username: Score Max Section: (check one) 07 - Sushant Athley, Tuesday 11:30am 08 - Aishwarya Bhide, Thursday 11:30am 09 - Phanindra
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 12: Sorting Algorithms MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Outline 2 Last week Implementation of the three tree depth-traversal algorithms Implementation of the BinarySearchTree
More informationCSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion
CSCI-1200 Data Structures Spring 2018 Lecture 7 Order Notation & Basic Recursion Review from Lectures 5 & 6 Arrays and pointers, Pointer arithmetic and dereferencing, Types of memory ( automatic, static,
More informationECE 242 Fall 14 Exam II Profs. Gao and Zink
ECE 242 Fall 14 Exam II Profs. Gao and Zink Name: ID Number: Maximum Achieved Question 1 20 Question 2 17 Question 3 20 Question 4 20 Question 5 23 Total 100 Instructions: Put your name and student number
More informationUniversity of Illinois at Urbana-Champaign Department of Computer Science. Second Examination
University of Illinois at Urbana-Champaign Department of Computer Science Second Examination CS 225 Data Structures and Software Principles Spring 2014 7-10p, Tuesday, April 8 Name: NetID: Lab Section
More informationMS OE. Quizzes. Name:
The following algorithm accepts a vector of coefficients and an x value and returns the corresponding polynomial evaluated at x. double PolynomialEval ( const ve cto r& c o e f f, double x ) 2
More informationl Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)
Final Exam Exercises Chapters 1-7 + 11 Write C++ code to: l Determine if a number is odd or even CS 2308 Fall 2016 Jill Seaman l Determine if a number/character is in a range - 1 to 10 (inclusive) - between
More informationCS 307 Midterm 2 Spring 2008
Points off 1 2 3 4 Total off Net Score Exam Number: CS 307 Midterm 2 Spring 2008 Name UTEID login name TA's Name: Mario Ruchica Vishvas (Circle One) Instructions: 1. Please turn off your cell phones and
More informationCOSC242 Lecture 7 Mergesort and Quicksort
COSC242 Lecture 7 Mergesort and Quicksort We saw last time that the time complexity function for Mergesort is T (n) = n + n log n. It is not hard to see that T (n) = O(n log n). After all, n + n log n
More informationECE368 Exam 2 Spring 2016
ECE368 Exam 2 Spring 2016 Thursday, April 7, 2016 15:00-16:15pm ARMS 1010 READ THIS BEFORE YOU BEGIN This is a closed-book, closed-notes exam. Electronic devices are not allowed. The time allotted for
More informationLecture 11: In-Place Sorting and Loop Invariants 10:00 AM, Feb 16, 2018
Integrated Introduction to Computer Science Fisler, Nelson Lecture 11: In-Place Sorting and Loop Invariants 10:00 AM, Feb 16, 2018 Contents 1 In-Place Sorting 1 2 Swapping Elements in an Array 1 3 Bubble
More information! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)
Final Exam Exercises CS 2308 Spring 2014 Jill Seaman Chapters 1-7 + 11 Write C++ code to: Determine if a number is odd or even Determine if a number/character is in a range - 1 to 10 (inclusive) - between
More informationUniversity of Illinois at Urbana-Champaign Department of Computer Science. Final Examination
University of Illinois at Urbana-Champaign Department of Computer Science Final Examination CS 225 Data Structures and Software Principles Fall 2009 7-10p, Tuesday, December 15 Name: NetID: Lab Section
More information- 1 - Handout #22S May 24, 2013 Practice Second Midterm Exam Solutions. CS106B Spring 2013
CS106B Spring 2013 Handout #22S May 24, 2013 Practice Second Midterm Exam Solutions Based on handouts by Eric Roberts and Jerry Cain Problem One: Reversing a Queue One way to reverse the queue is to keep
More informationLINKED LISTS cs2420 Introduction to Algorithms and Data Structures Spring 2015
LINKED LISTS cs2420 Introduction to Algorithms and Data Structures Spring 2015 1 administrivia 2 -assignment 5 due tonight at midnight -assignment 6 is out -YOU WILL BE SWITCHING PARTNERS! 3 assignment
More informationTest #2. Login: 2 PROBLEM 1 : (Balance (6points)) Insert the following elements into an AVL tree. Make sure you show the tree before and after each ro
DUKE UNIVERSITY Department of Computer Science CPS 100 Fall 2003 J. Forbes Test #2 Name: Login: Honor code acknowledgment (signature) Name Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Problem
More informationCOMP Data Structures
COMP 2140 - Data Structures Shahin Kamali Topic 5 - Sorting University of Manitoba Based on notes by S. Durocher. COMP 2140 - Data Structures 1 / 55 Overview Review: Insertion Sort Merge Sort Quicksort
More informationCSE332 Summer 2012 Final Exam, August 15, 2012
Name: UW NetID: CSE332 Summer 2012 Final Exam, August 15, 2012 Please do not turn the page until the bell rings. Rules: The exam is closed-book and limited-note. You are permitted a single, handwritten
More informationCS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: Instructions
CS 112 Final May 8, 2008 (Lightly edited for 2012 Practice) Name: BU ID: This exam is CLOSED book and notes. Instructions The exam consists of six questions on 11 pages. Please answer all questions on
More informationCornell University Computer Science 211 Second Preliminary Examination 18 April 2006
Cornell University Computer Science 211 Second Preliminary Examination 18 April 2006 There are 4 problems on this exam. It is 8 pages long, so make sure you have the whole exam. You will have 1 1 hours
More informationCS314 Exam 2 - Spring Suggested Solution and Criteria 1
CS314 Spring 2016 Exam 2 Solution and Grading Criteria. Grading acronyms: AIOBE - Array Index out of Bounds Exception may occur BOD - Benefit of the Doubt. Not certain code works, but, can't prove otherwise
More informationCSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators)
Name: Email address: Quiz Section: CSE 332 Spring 2014: Midterm Exam (closed book, closed notes, no calculators) Instructions: Read the directions for each question carefully before answering. We will
More information1) Holiday Lights 30 Points
1) Holiday Lights 30 Points It's the holiday season, which means one thing; holiday lights! You have unboxed your string of lights to hang, but have one problem; though they are multicolored, they are
More informationUNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger
UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division CS61B Fall 2011 P. N. Hilfinger Test #2 (with corrections) READ THIS PAGE FIRST. Please do
More informationLesson 12: Recursion, Complexity, Searching and Sorting. Modifications By Mr. Dave Clausen Updated for Java 1_5
Lesson 12: Recursion, Complexity, Searching and Sorting Modifications By Mr. Dave Clausen Updated for Java 1_5 1 Lesson 12: Recursion, Complexity, and Searching and Sorting Objectives: Design and implement
More informationFinal Examination CS 125 Introduction to Computer Science Fall Hours
University of Illinois at Urbana-Champaign Department of Computer Science Final Examination CS 125 Introduction to Computer Science Fall 2009 3 Hours Last Name: First Name: NetID: @ illinois.edu PLEASE
More informationCOP 3502 Spring 2018 Study Union Review
Page 1 COP 3502 Spring 2018 Study Union Review Alec May Table of Contents: Tries 2 Heaps 3 Hash Tables 5 Base Conversion 6 Bitwise Operators 7 Backtracking 8 Sorts 9 Linked Lists 10 Tips and Resources
More informationCS300 Final Review Questions 1
CS300 Final Review Questions 1 This is not a complete list of questions and topics, but a good sampling of questions that will help you study for the final. I strongly advise you to work through every
More informationCSCI-1200 Data Structures Spring 2017 Lecture 15 Problem Solving Techniques, Continued
CSCI-1200 Data Structures Spring 2017 Lecture 15 Problem Solving Techniques, Continued Review of Lecture 14 General Problem Solving Techniques: 1. Generating and Evaluating Ideas 2. Mapping Ideas into
More informationCmpSci 187: Programming with Data Structures Spring 2015
CmpSci 187: Programming with Data Structures Spring 2015 Lecture #22, More Graph Searches, Some Sorting, and Efficient Sorting Algorithms John Ridgway April 21, 2015 1 Review of Uniform-cost Search Uniform-Cost
More informationSorting. Bringing Order to the World
Lecture 10 Sorting Bringing Order to the World Lecture Outline Iterative sorting algorithms (comparison based) Selection Sort Bubble Sort Insertion Sort Recursive sorting algorithms (comparison based)
More informationMidterm Exam 2 CS 455, Fall 2014
Name: USC NetId (e.g., ttrojan): Midterm Exam 2 CS 455, Fall 2014 November 11, 2014 There are 8 problems on the exam, with 62 points total available. There are 8 pages to the exam, including this one;
More informationCS314 Exam 2 - Fall Suggested Solution and Criteria 1
CS314 Fall 2017 Exam 2 Solution and Grading Criteria. Grading acronyms: AIOBE - Array Index out of Bounds Exception may occur BOD - Benefit of the Doubt. Not certain code works, but, can't prove otherwise
More informationMidterm 1 Exam Principles of Imperative Computation. Thursday 6 th October, This exam is closed-book with one sheet of notes permitted.
Midterm 1 Exam 15-122 Principles of Imperative Computation Thursday 6 th October, 2016 Name: Andrew ID: Recitation Section: Instructions This exam is closed-book with one sheet of notes permitted. You
More informationPRACTICE MIDTERM EXAM #2
This practice exam is based on the actual midterm exam from Cynthia s Spring 2014 class. It did not include a classes problem (which you should expect this quarter), and the memory/pointers problem covered
More informationCS 455 Final Exam Fall 2012 [Bono] Dec. 17, 2012
Name: USC loginid (e.g., ttrojan): CS 455 Final Exam Fall 2012 [Bono] Dec. 17, 2012 There are 6 problems on the exam, with 70 points total available. There are 7 pages to the exam, including this one;
More informationNo aids allowed. No books. No notes. No calculators. No computers. No communicating devices.
University of Toronto Faculty of Applied Science and Engineering ECE 244F PROGRAMMING FUNDAMENTALS Fall 2008 Final Examination Examiner: C. Gibson, A. Goel, and M. Stumm Duration: Two and a Half Hours
More informationFirst Examination. CS 225 Data Structures and Software Principles Spring p-9p, Tuesday, February 19
Department of Computer Science First Examination CS 225 Data Structures and Software Principles Spring 2008 7p-9p, Tuesday, February 19 Name: NetID: Lab Section (Day/Time): This is a closed book and closed
More informationMARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012
MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012 Instructor: K. S. Booth Time: 70 minutes (one hour ten minutes)
More informationMPATE-GE 2618: C Programming for Music Technology. Syllabus
MPATE-GE 2618: C Programming for Music Technology Instructor Dr. Schuyler Quackenbush schuyler.quackenbush@nyu.edu Lab Teaching Assistant TBD Description Syllabus MPATE-GE 2618: C Programming for Music
More informationMCS 360 Exam 2 11 November In order to get full credit, you need to show your work.
MCS 360 Exam 2 11 November 2015 Name: Do not start until instructed to do so. In order to get full credit, you need to show your work. You have 50 minutes to complete the exam. Good Luck! Problem 1.a /15
More informationTopics Recursive Sorting Algorithms Divide and Conquer technique An O(NlogN) Sorting Alg. using a Heap making use of the heap properties STL Sorting F
CSC212 Data Structure t Lecture 21 Recursive Sorting, Heapsort & STL Quicksort Instructor: George Wolberg Department of Computer Science City College of New York @ George Wolberg, 2016 1 Topics Recursive
More informationCS 455 Final Exam Spring 2017 [Bono] May 10, 2017
Name: USC NetID (e.g., ttrojan): CS 455 Final Exam Spring 2017 [Bono] May 10, 2017 There are 7 problems on the exam, with 74 points total available. There are 12 pages to the exam (6 pages double-sided),
More informationMidterm I Exam Principles of Imperative Computation Frank Pfenning, Tom Cortina, William Lovas. September 30, 2010
Midterm I Exam 15-122 Principles of Imperative Computation Frank Pfenning, Tom Cortina, William Lovas September 30, 2010 Name: Andrew ID: Instructions This exam is closed-book with one sheet of notes permitted.
More informationTutorial Letter 102/1/2012 Programming: Data Structures
/1/2012 Tutorial Letter 102/1/2012 Programming: Data Structures COS2611 Semester 1 School of Computing This tutorial letter contains important information regarding the Exam. Bar code List of all tutorial
More informationCS 314 Exam 2 Spring
Points off 1 2 3 4 5 Total off CS 314 Exam 2 Spring 2017 Your Name Your UTEID Instructions: 1. There are 5 questions on this test. 100 points available. Scores will be scaled to 200 points. 2. You have
More informationData Structures and Algorithms
Data Structures and Algorithms First Semester 2017/2018 Linked Lists Eng. Anis Nazer Linked List ADT Is a list of nodes Each node has: data (can be any thing, int, char, Person, Point, day,...) link to
More informationMIPS Assembly: Quicksort. CptS 260 Introduction to Computer Architecture Week 4.1 Mon 2014/06/30
MIPS Assembly: Quicksort CptS 260 Introduction to Computer Architecture Week 4.1 Mon 2014/06/30 This Week 06/30 Mon Quicksort (overview) 07/01 Tue Quicksort (partition, HW6) 07/02 Wed Review HW1 HW5 Topics
More informationCS 3343 (Spring 2018) Assignment 4 (105 points + 15 extra) Due: March 9 before class starts
CS 3343 (Spring 2018) Assignment 4 (105 points + 15 extra) 1. (20 points) Quick sort. Due: March 9 before class starts a. (5 points) Study the pseudocode of the Partition algorithm in slide set 7-qsort.ppt.
More informationUniversity of Illinois at Urbana-Champaign Department of Computer Science. First Examination
University of Illinois at Urbana-Champaign Department of Computer Science First Examination CS 225 Data Structures and Software Principles Spring 2009 7p-9p, Tuesday, Feb 24 Name: NetID: Lab Section (Day/Time):
More information(the bubble footer is automatically inserted into this space)
CS 2150 Final Exam, spring 2016 Page 1 of 10 UVa userid: CS 2150 Final Exam, spring 2016 Name You MUST write your e-mail ID on EACH page and bubble in your userid at the bottom of this first page. And
More informationCS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today Recursive Sorting Methods and their Complexity: Mergesort Conclusions on sorting algorithms and complexity Next Time:
More informationCS 112 Final May 8, 2008 (Lightly edited for 2011 Practice) Name: BU ID: Instructions GOOD LUCK!
CS 112 Final May 8, 2008 (Lightly edited for 2011 Practice) Name: BU ID: This exam is CLOSED book and notes. Instructions The exam consists of six questions on 11 pages. Please answer all questions on
More informationFaster Sorting Methods
Faster Sorting Methods Chapter 9 Contents Merge Sort Merging Arrays Recursive Merge Sort The Efficiency of Merge Sort Iterative Merge Sort Merge Sort in the Java Class Library Contents Quick Sort The Efficiency
More informationECE 250 Data Structures and Algorithms MID-TERM EXAMINATION /5:30-7:00
The examination is out of 64 marks. ECE 250 Data Structures and Algorithms MID-TERM EXAMINATION 2008-2-13/5:30-7:00 Instructions: No aides. Turn off all electronic media and store them under your desk.
More informationECE 190 Final Exam. Practice exam
ECE 190 Final Exam Practice exam Problem 1: MP5-related Problem 2: LC-3 Problem 3: Debugging Problem 4: Linked data structures Problem 5: Multi-dimensional arrays Please note You are allowed to bring four
More informationCSE 373 Final Exam 3/14/06 Sample Solution
Question 1. (6 points) A priority queue is a data structure that supports storing a set of values, each of which has an associated key. Each key-value pair is an entry in the priority queue. The basic
More informationComputer Science 1 Ah
UNIVERSITY OF EDINBURGH course CS0077 COLLEGE OF SCIENCE AND ENGINEERING SCHOOL OF INFORMATICS Computer Science 1 Ah Resit Examination Specimen Solutions Date: Monday 1st September 2003 Time: 09:30 11:00
More informationTopics for CSCI 151 Final Exam Wednesday, May 10
Topics for CSCI 151 Final Exam Wednesday, May 10 Java and Programming Techniques Types Inheritance Generics Abstract classes and interfaces Exceptions Recursion Writing recursive methods Dynamic Programming
More informationCS314 Exam 1 - Fall Suggested Solution and Criteria 1
CS314 fall 2016 Exam 2 Solution and Grading Criteria. Grading acronyms: AIOBE - Array Index out of Bounds Exception may occur BOD - Benefit of the Doubt. Not certain code works, but, can't prove otherwise
More informationSorting. Task Description. Selection Sort. Should we worry about speed?
Sorting Should we worry about speed? Task Description We have an array of n values in any order We need to have the array sorted in ascending or descending order of values 2 Selection Sort Select the smallest
More informationCS 2150 Exam 1, Spring 2018 Page 1 of 6 UVa userid:
CS 2150 Exam 1, Spring 2018 Page 1 of 6 UVa userid: CS 2150 Exam 1 Name You MUST write your e-mail ID on EACH page and put your name on the top of this page, too. If you are still writing when pens down
More informationCS 2604 Data Structures Midterm Summer 2000 U T. Do not start the test until instructed to do so!
VIRG INIA POLYTECHNIC INSTITUTE AND STATE U T PROSI M UNI VERSI TY Instructions: Print your name in the space provided below. This examination is closed book and closed notes. No calculators or other computing
More information