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

Chapter 6 Questions with Answers - Data Structures and Algorithms | CS 331, Assignments of Data Structures and Algorithms

Material Type: Assignment; Class: Data Structures and Algorithms; Subject: Computer Science (CS); University: Jacksonville State University; Term: Summer II 2006;

Typology: Assignments

Pre 2010

Uploaded on 08/18/2009

koofers-user-7dt-1
koofers-user-7dt-1 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 331 Chapter 6 Questions
Page 1 of 3
1) What is the corrected input if the following line is typed on a keyboard:
ywwdshr←←wde
(where represents the backspace character)?
a) ywdswe
b) ywwdwde
c) ywdshwe
d) ywdswd
Answer: a.
2) If the array:
6, 2, 7, 13, 5, 4
is added to a stack, in the order given, which number will be the first number to be removed from the stack?
a) 6
b) 2
c) 5
d) 4
Answer: d.
3) The item that is removed first from a stack is called the ______ of the stack.
a) front
b) top
c) base
d) prime
Answer: b.
4) If the array:
6, 21, 35, 3, 6, 2, 13
is added to a stack, in the order given, which of the following is the top of the stack?
a) 2
b) 6
c) 3
d) 13
e) 35
Answer: d.
5) If the array:
6, 2, 7, 13, 5, 4
is added to a queue, in the order given, which number will be the first number to be removed from the queue?
a) 6
b) 2
c) 5
d) 4
Answer: a.
6) The last-in, first-out (LIFO) property is found in the ADT ______.
a) list
b) stack
c) queue
d) tree
Answer: b.
7) The first in, first out (FIFO) property is found in the ADT ______.
a) list
b) stack
c) queue
pf3

Partial preview of the text

Download Chapter 6 Questions with Answers - Data Structures and Algorithms | CS 331 and more Assignments Data Structures and Algorithms in PDF only on Docsity!

  1. What is the corrected input if the following line is typed on a keyboard: yww←dshr←←wd←e (where ← represents the backspace character)? a) ywdswe b) ywwdwde c) ywdshwe d) ywdswd Answer: a.

  2. If the array: 6, 2, 7, 13, 5, 4 is added to a stack, in the order given, which number will be the first number to be removed from the stack? a) 6 b) 2 c) 5 d) 4 Answer: d.

  3. The item that is removed first from a stack is called the ______ of the stack. a) front b) top c) base d) prime Answer: b.

  4. If the array: 6, 21, 35, 3, 6, 2, 13 is added to a stack, in the order given, which of the following is the top of the stack? a) 2 b) 6 c) 3 d) 13 e) 35 Answer: d.

  5. If the array: 6, 2, 7, 13, 5, 4 is added to a queue, in the order given, which number will be the first number to be removed from the queue? a) 6 b) 2 c) 5 d) 4 Answer: a.

  6. The last-in, first-out (LIFO) property is found in the ADT ______. a) list b) stack c) queue d) tree Answer: b.

  7. The first in, first out (FIFO) property is found in the ADT ______. a) list b) stack c) queue

d) tree Answer: c.

  1. The ______ method of the ADT stack adds an item to the top of the stack. a) createStack b) push c) pop d) peek Answer: b.

  2. The ______ method of the ADT stack retrieves and then removes the top of the stack. a) createStack b) push c) pop d) peek Answer: c.

  3. The ______ method of the ADT stack retrieves the top of the stack, but does not change the stack. a) createStack b) push c) pop d) peek Answer: d.

  4. Which of the following methods of the ADT stack accepts a parameter? a) push b) pop c) createStack d) peek Answer: a.

  5. Which of the following strings contains balanced braces? a) ab{cde{fg}hi{jkl} b) ab{cde{fghi}j}kl} c) {abc{de}{fg}hij}kl d) {ab{cde{fgh}ijkl} Answer: c.

  6. If a stack is used by an algorithm to check for balanced braces, which of the following is true once the end of the string is reached? a) the stack is empty b) the stack has one “{” c) the stack has one “}” d) the stack has one “{” and one “}” Answer: a.

  7. Which of the following operations of the ADT stack does not throw a StackException? a) push b) pop c) popAll d) peek Answer: c.

  8. The pop operation throws a StackException when it tries to ______. a) add an item to an empty stack b) add an item to an array-based implementation of a stack that is already full