Vous êtes sur la page 1sur 4

Course Unit: Data structures and Algorithms Programming Course Work

1
Course: DIT/ DCS
Group Work: Each Two Members
Deadline: 17th /06/2017 Before 1:00pm
Marks: 40%
Mode: Handwritten (Good Handwriting)

2. Let us consider the following statements:


int *p;
int num;
In these statements, p is a pointer variable of type int and num is a variable of type int.
Let us assume that memory location 1200 is allocated for p and memory location 1800 is for
num. (See Figure 3-1.)

With illustrations, explain the values of each variable after execution

Lecturer: Serunjogi Ismail


2
4. Write C Language Statements to do the following

5. Consider the following statements:

Lecturer: Serunjogi Ismail


struct stackType stack;

3
int x, y;
Show what is output by the following segment of code:
x = 4;
y = 0;
stack.push(7);
stack.push(x);
stack.push(x + 5);
y = stack.top();
stack.pop();
stack.push(x + y);
stack.push(y - 2);
stack.push(3);
x = stack.top();
stack.pop();
printf("x = %d\n", x);
printf("y = %d\n", y);
while (!stack.isEmptyStack())
{
printf("%d\n", stack.top());
stack.pop();
}
6. Evaluate the following postfix expressions:

7. Convert the following infix expressions to postfix

8. Consider the following statements:


struct queueType queue;
int x, y;
Show what output by the following segment of code is:
x = 4;
y = 5;
queue.addQueue(x);
Lecturer: Serunjogi Ismail
queue.addQueue(y);

4
x = queue.front();
queue.deleteQueue();
queue.addQueue(x + 5);
queue.addQueue(16);
queue.addQueue(x);
queue.addQueue(y - 3);
printf("Queue Elements: ");
while (!queue.isEmptyQueue())
{
printf("%d ", queue.front());
queue.deleteQueue();
}
printf("\n");

Lecturer: Serunjogi Ismail

Vous aimerez peut-être aussi