0% found this document useful (0 votes)
48 views2 pages

CSC 250 - Data Structure - Quiz Sample Questions

The document contains sample quiz questions for a Computer Science course on Data Structures, specifically focusing on stacks and dynamic arrays. It includes multiple-choice questions about stack properties, dynamic array declarations, and the implementation of a push function. Additionally, it presents a code snippet that manipulates a stack and a queue, asking what the function achieves in general.

Uploaded by

Kareem Hamdy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views2 pages

CSC 250 - Data Structure - Quiz Sample Questions

The document contains sample quiz questions for a Computer Science course on Data Structures, specifically focusing on stacks and dynamic arrays. It includes multiple-choice questions about stack properties, dynamic array declarations, and the implementation of a push function. Additionally, it presents a code snippet that manipulates a stack and a queue, asking what the function achieves in general.

Uploaded by

Kareem Hamdy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Computer Science School

CSC 250 - Data Structures

Quiz
Sample Questions

1 Which of the following is true about stacks?

A) A stack is a last-in, first-out B) A stack is a random-access


structure structure
C) A stack is a first-in, first-out D) A stack is a last-in, first-out and
structure sometimes it’s a random-access structure

2 Choose the statements needed for the declaration of a dynamically allocated array that
holds 500 characters.

A) char * arrayptr = B) char * arrayptr;


char [500]; arrayptr =
new char [500];
C) char * arrayptr [500]; D) char arrayptr;
arrayptr =
new char [500];
3 Consider the following function, the push function for the array implementation of the
stack.

void Push(int newItem) {


if( IsFull() )
cout<<"Stack is overflow" << endl;
else {
/* add code here */
}
}
Computer Science School
CSC 250 - Data Structures
3.1 Complete the missing code (where indicated by comments)

A) items[top] = newItem; B) items[top] = newItem;


top++;

C) top++; D) top++;
items[top] = newItem;

3.2 IsFull function, will return an output of type char.

A) True B) False

3.3 IsFull function, will return true if and only if there is an empty space in the stack.

A) True B) False

3.4 The Push function, is called when a new item is to be added to the stack.

A) True B) False

4 Suppose we have declared S as a stack, and Q as a Queue.


int val;
while (!isEmpty(Q)) {
val = deQueue(Q);
push(S, val);
}
while (!isEmpty(S)) {
val = pop(S);
enQueue(Q, val);
}

What does the above function do in general?

A) Removes the last from Q B) Keeps the Q same as it was


before the call
C) Makes Q empty D) Reverses the Q

You might also like