Вы находитесь на странице: 1из 4

# Course Unit: Data structures and Algorithms Programming Course Work

1
Course: DIT/ DCS
Group Work: Each Two Members
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.)

## Lecturer: Serunjogi Ismail

2
4. Write C Language Statements to do the following

## 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:

## 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;
Lecturer: Serunjogi Ismail

4
x = queue.front();
queue.deleteQueue();