Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

COMP380 Section 71 Quiz 2 - Data Structures I, Quizzes of Data Structures and Algorithms

A quiz for the data structures i course offered by wentworth institute of technology's division of professional and continuing studies in spring, 2006. The quiz covers topics such as doubly linked lists, recursion, arrays vs linked lists, stacks, and the list interface.

Typology: Quizzes

Pre 2010

Uploaded on 08/19/2009

koofers-user-5kh
koofers-user-5kh 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
NAME________________________________________________ DATE____________
Wentworth Institute of Technology
Division of Professional and Continuing Studies
COMP380 Section 71 – Data Structures I - Spring, 2006
Quiz Number 2 – OPEN BOOK
1. Add the appropriate items to the below diagram to make it into a Doubly Linked List (ie add the missing fields
and missing arrows and indicators of the front and rear of the list and label the fields)
2. Given the below recursive method, what is the value of
int ffudge( int n) {
if (n == 0) return 1;
if (n==1 ) return 2;
return 3*ffudge(n-2) + 2*ffudge(n-1);
}
a. ffudge(3)
b. ffudge(6)
3.
a. What operation is EASY to do for an array-based list, but is hard to do with Linked? Why?
b. What operation is EASY to do for Linked lists, but is Hard to do with array-based lists? Why?
4.
a. How can you avoid popping from an empty stack?
b. What message do you get if you do attempt to pop from an empty stack?
5. What does this statement do in the context of operating on a Linked list?
prior.next = curr.next;
/app/work/qkdc8b-479270-2765041-quiz2comp380sp06-doc.doc 1 12/4/2020
pf2

Partial preview of the text

Download COMP380 Section 71 Quiz 2 - Data Structures I and more Quizzes Data Structures and Algorithms in PDF only on Docsity!

NAME________________________________________________ DATE____________

Wentworth Institute of Technology

Division of Professional and Continuing Studies

COMP380 Section 71 – Data Structures I - Spring, 2006

Quiz Number 2 – OPEN BOOK

  1. Add the appropriate items to the below diagram to make it into a Doubly Linked List (ie add the missing fields and missing arrows and indicators of the front and rear of the list and label the fields)
  2. Given the below recursive method, what is the value of int ffudge( int n) { if (n == 0) return 1; if (n==1 ) return 2; return 3ffudge(n-2) + 2ffudge(n-1); } a. ffudge(3) b. ffudge(6)
  3. a. What operation is EASY to do for an array-based list, but is hard to do with Linked? Why? b. What operation is EASY to do for Linked lists, but is Hard to do with array-based lists? Why?
  4. a. How can you avoid popping from an empty stack? b. What message do you get if you do attempt to pop from an empty stack?
  5. What does this statement do in the context of operating on a Linked list? prior.next = curr.next; /app/work/qkdc8b-479270-2765041-quiz2comp380sp06-doc.doc 1 12/4/

NAME________________________________________________ DATE____________

  1. Mark each statement true or false ______When the top of a stack points to null, this means the stack is empty. ______Stacks can be implemented either as a linked list or as an array ______The push operation for a stack takes 2 arguments: the item and a pointer to the prior top of the stack ______A stack is FIFO structure ______Popping from an empty stack is legal, but will return a null item
  2. What does the below set of statements do in the context of a “doubly-linked” list: newNode.prev = curr.prev; newNode.next = curr; (curr.prev).next = newNode; curr.prev = newNode;
  3. List 5 appropriate uses of stacks a. ________________________________________________________________________________ b._________________________________________________________________________________ c._________________________________________________________________________________ d._________________________________________________________________________________ e__________________________________________________________________________________
  4. Just as in question number 1, add the appropriate items to the below diagram to make it into a stack.
  5. List the methods (include the return datatypes and arguments with datatypes) that need to be implemented in order for a class to implement the List interface /app/work/qkdc8b-479270-2765041-quiz2comp380sp06-doc.doc 2 12/4/