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

COSC 350 Quiz 1: Data Structures and Algorithms - Prof. Joseph D. Sloan, Quizzes of Data Structures and Algorithms

A quiz from a university-level computer science course, cosc 350, focused on data structures and algorithms. The quiz covers various topics such as stacks, queues, deques, prefix and postfix notation, recursion, and time complexity. Students are required to identify the appropriate data structure for given scenarios, rewrite expressions in prefix and postfix notation, evaluate arithmetic expressions, convert numbers to other bases, write recursive functions, and analyze time complexity.

Typology: Quizzes

Pre 2010

Uploaded on 08/16/2009

koofers-user-ur5
koofers-user-ur5 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COSC 350 Page 1 of 4 2/2/2009
COSC 350: Quiz 1 Name _____________________
Through Section 4.2
1. (15 pts.) Which data structure, a stack, queue, or deque, would be the most
appropriate for each of the following?
a) Holding activation records for subroutine calls
b) A LILO data structure
c) Keeping track of partial paths that need to be searched with a breadth-first search
strategy
d) Simulating a deck of cards where cards are dealt from the top of the deck and all
returned cards are added to the bottom of the deck
e) Simulating a ticket-line at the theater where people either, a) arrive, enter the line,
see it is too long, and leave before anyone else arrives, or, b) arrive, enter the line,
and wait until it is their turn to buy a ticket leaving the line once the ticket is
bought
2. (6 pts.) Rewrite (a+b)*(c+d) – e in:
a) prefix notation
b) postfix notation
3. (6 pts.) Evaluate the following:
a) + * + 1 2 3 4 * 5
b) 1 2 3 4 * + * 5 +
pf3
pf4

Partial preview of the text

Download COSC 350 Quiz 1: Data Structures and Algorithms - Prof. Joseph D. Sloan and more Quizzes Data Structures and Algorithms in PDF only on Docsity!

COSC 350: Quiz 1 Name _____________________

Through Section 4.

  1. (15 pts.) Which data structure, a stack , queue , or deque , would be the most appropriate for each of the following? a) Holding activation records for subroutine calls b) A LILO data structure c) Keeping track of partial paths that need to be searched with a breadth-first search strategy d) Simulating a deck of cards where cards are dealt from the top of the deck and all returned cards are added to the bottom of the deck e) Simulating a ticket-line at the theater where people either, a) arrive, enter the line, see it is too long, and leave before anyone else arrives, or, b) arrive, enter the line, and wait until it is their turn to buy a ticket leaving the line once the ticket is bought
  2. (6 pts.) Rewrite (a+b)*(c+d) – e in: a) prefix notation b) postfix notation
  3. (6 pts.) Evaluate the following: a) + * + 1 2 3 4 * 5 b) 1 2 3 4 * + * 5 +
  1. (4 pts.) Use the base-conversion algorithm from the text to convert 11110 to base 7.
  2. (8 pts.) Rewrite the following code using a recursive function def myIndex(lst, item): at = 0 while not item == lst[at]: at = at + 1 return at
  3. (10 pts.) Write a recursive function to double each item on a list of numbers. For example, double[1,2,3,4,5] would return [2,4,6,8,10].
  1. In this problem you will develop an implementation for a Deque. a) (7 pts.) Give an ADT for a Deque. b) (14 pts.) Give a Python class definition for your ADT using Python’s built-in list data type. Pledged: ________________________________________________________________