You are on page 1of 17

2022-2021 ‫ جامعة بيشة ترم الشتاء‬, ‫اختبار الميد تيرم لمادة هياكل بيانات داتا ستركشر‬

‫ منير‬: ‫األستاذ‬

1 ‫السؤال‬

2.1) After execution of the following statements, what value does the variable q contain? int *p,
*q; p = new int; q = p; delete p; p = NULL;

the address of p

the address of the deallocated memory cell

the value NULL

q does not point to anything

2 ‫السؤال‬

2.1) The following method is an enqueue method:

//--------------------------------------------

void enqueue(int data)

node *N=new node;

N->next = NULL;

N->info = data;

if (rear == NULL)
front=rear=N;

else

rear->next = N;

rear = ____;

The blank is:

rear->next

next
temp

Raer-<next

Top of the stack always contains the new node

True
4 ‫السؤال‬

1.2) Typically, __ is used by a compiler to evaluate the postfix expression.

array

queue

stack

linked-list

5 ‫السؤال‬

1.2) What behavior does the stack exhibit?

first in, first out

first in, never out

first-in, last-out,

last in, last out

6 ‫السؤال‬

1.2) Which of the following strings contains balanced braces?

ab{cde{fg}hi{jkl}

ab{cde{fghi}j}kl}

{abc{de}{fg}hij}kl

{ab{cde{fgh}ijkl}

1.2) Which of the following operations is performed more efficiently by doubly linked list than
by linear linked list?

Deleting a node whose location is given.

Inserting a node after the node with a given location

Searching an unsorted list for a given item.


Traversing the list to process each node.

7 ‫السؤال‬

1.2) The item that is removed first from a stack is called the __ of the stack.

A. front

B. base

C. prime

D. top

8 ‫السؤال‬

1.2) The __ operation of the stack adds an item to the top of the stack.

createStack

push

pop

getTop

9 ‫السؤال‬

1.2) What behavior does the circular queue exhibit:

last in, first out

last in, never out

first in, last out

first in, first out

10 ‫السؤال‬

1.2) Which of the following is like a line of people?


list

stack

queue

tree

3 ‫السؤال‬

1.2) A(n) __ is a construct that can be defined to store a collection of data.

data structure

module

abstract data type

method

11 ‫السؤال‬

1.2) Which of the following code fragments deletes the item at the front of a queue
represented by a circular array?

front = MAX_QUEUE - front; --count;

front = front - back; --count;

front = (front+1) % MAX_QUEUE; --count;

front = (back+1) %MAX_QUEUE; --count;

4 ‫السؤال‬

1.2) A linked list contains components, called __, which are linked to one another.

nodes

arrays

vectors

references
5 ‫السؤال‬

1.2) The members of a node structure can be accessed with the __ operator.

[]

&

->

At

2.1) Imagine you have an empty stack of integers, S, with 5 elements size, and two integer
numbers x and y.

Stack S;

int x=2,y=8;

S.push(y-x);

S.push(y+x);

x= y+S.pop();

while(!S.full())

S.push(++x);

if (S.pop()>7)
y= S.pop();

After executing the above code, the value of y will be:

23

21

24

25

13 ‫السؤال‬

1.2) Which of the following operations leaves a queue unchanged?

enqueue

dequeue

None

getFront

14 ‫السؤال‬

1.2) What is the need for a circular queue?

Implement LIFO principle in queues

To delete elements based on priority

Effective usage of memory

Easier computations

15 ‫السؤال‬

1.2) Which of the following is NOT a queue operation?

enqueue

isEmpty
pop

getFront

8 ‫السؤال‬

2.1) If the elements “A”, “B”, “C” and “D” are placed in a queue and are removed one at a time,
in what order will they be removed?

ABCD

DCBA

ACBD

ABDC

What is the value of the following postfix expression: 6 2 – 7 4 + *?

24

12

44

32

10 ‫السؤال‬

2.1) The following method pushes an element into a stack:

void push(int x)

node *t=new node;

t->data=x;
t->next=NULL;

if (top == NULL)

top=t;

else {

t->next= top;

_______;

The blank is:

top=top

top = top->next

top = t

top = temp

18 ‫السؤال‬

2.1) The following method is the stack pop method:

//------------------------------------------------------------------------
char pop()

stack* top1 =top;

char ch= top->data;

top=top-> _______;

free(top1);

return ch;

The blank is ______.

top1

top

stack
next

11 ‫لسؤال‬

2.1) The following method receives


the LL head and insert a new node at
the begining:

//-------------------------------------------

Node insertFirst(Node *cr,int info)

Node *New=new Node;

New->item=info;

New->next=cr;
cr=____ ;

return *cr;

The blank is:

cr

New

next

cr->next

13 ‫السؤال‬

1.2) The __ operation retrieves and removes the front of a queue.

isEmpty

enqueue

dequeue

getFront

21 ‫السؤال‬

1.2) The insertion operation of the linked list can insert new items ___

only at the end of the list

only at the front of the list

only in the middle of the list

into any position of the list

22 ‫السؤال‬

1.2) To delete a node N from a linear linked list, you will need to __.
set the pointer next in the node that precedes N to point to the node that follows N

set the pointer next in the node that precedes N to point to N

set the pointer next in the node that follows N to point to the node that precedes N

set the pointer next in N to point to the node that follows N

18 ‫السؤال‬

1.2) Which of the following C++ statements insert a new node, pointed to by newPtr, into an
empty queue represented by a linear linked list?

newPtr->next = backPtr;

backPtr->next = newPtr; frontPtr = newPtr;

newPtr->next = backPtr; newPtr->next = frontPtr;

frontPtr = newPtr; backPtr = newPtr;

19 ‫السؤال‬

2.1) Which of the following statements deletes the first node of a linear linked list that has 10
nodes?

head->next = cur->next;

head = head->next;

prev->next = cur->next;

head = NULL;

23 ‫السؤال‬

1.2) The last node of a linear linked list __.

has the value NULL

has a next pointer whose value is NULL

has a next pointer that points to the first node of the list
cannot store any data

24 ‫السؤال‬

1.2) The insertion operation of the linked list can insert new items __.

only at the front of the list

only at the end of the list

only in the middle of the list

none

22 ‫السؤال‬

1.2) Which of the following operations of the stack accepts a parameter?

isEmpty

createStack

destroyStack

push

2.1) Imagine you have an empty stack of integers, S, with 5 elements size, and two integer
numbers x and y.

Stack S;

int x=2,y=8;
S.push(y-x);

S.push(y+x);

x= y+S.pop();

while(!S.full())

S.push(x--);

if (S.pop()>7)

y= S.pop();

After executing the above code, the value of x will be:

16

15

18

17

24 ‫السؤال‬

1.2) Which of the following statement is invalid with respect to balancing symbols?

{(A+B) + [C+D]}

[{A+B}-{C-[D+E]}]

[(A+B) + (C-D)]

((A+B) + (C+D)

25 ‫السؤال‬

1.2) The __ operation of the stack retrieves the top of the stack, but does not change the stack.

createStack

push

pop

getTop

You might also like