Lecture14-5 - DataStructures CSCI 132, Spring 2012 Lecture...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Data Structures   CSCI 132, Spring 2012 Lecture 14 Review for Exam 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Problem 1. Write a function that counts how many even numbers there are in an integer linked list. The function should have one parameter, a pointer to a linked list. The function should not alter the list. It should return an integer value equal to the number of even numbers in the list. You can assume the following definition: struct Node { int data; Node *next; Node(); Node(Node_entry item, Node *add_on = NULL); }
Background image of page 2
3 Problem 2. 2) Consider the following code: int *y; int *x; x = new int; *x = 15; *x += 2; y = x; *y *= 2; a) Draw a diagram to represent the pointers as each line of this code is executed. b) What are the values of *x and *y after executing this code?
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Problem 3. What is the output of the following Code? typedef int Stack_entry; typedef int Queue_entry; int main(void) { Stack pile; Queue lineUp; int number; for (int i = 0; i < 5; i++ ) { pile.push(i * 2); lineUp.append(i + 2); } while (!pile.empty()) {
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

Lecture14-5 - DataStructures CSCI 132, Spring 2012 Lecture...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online