DSA Quiz #1_ A_S17.pdf - Bahria University Lahore Campus Department of Computer Science DATA STRUCTURES AND ALGORITHM QUIZ 01 MARKS 20 Instructor Name

DSA Quiz #1_ A_S17.pdf - Bahria University Lahore Campus...

This preview shows page 1 - 4 out of 4 pages.

Page 1 of 4 Bahria University Lahore Campus Department of Computer Science D ATA S TRUCTURES AND ALGORITHM Q UIZ # 01 S PRING 2017 M ARKS : 20 T IME : 20M IN Instructor Name: Mr. Tahir Iqbal Program: BSCS 4A & 4B Q1) Given the following declaration of node and illustration of a linked list with the pointers P1 and P2. struct nodeType { int info; nodeType *link; }; nodeType *P1, *P2, list; a. What is the output of each of the following C++ statements? i. cout << list->info; ii. cout << list->link->info; iii. cout << p1->info; iv. cout << p2->link->info; v. cout << list->link->link->info; vi. cout << list->link->link->link->info; Q2) What is the output of the following C++ code.
Image of page 1
Page 2 of 4 a. list = new nodeType; list->info = 10; ptr = new nodeType; ptr->info = 13; ptr->link = NULL; list->link = ptr; ptr = new nodeType; ptr->info = 18; ptr->link = list->link; list->link = ptr; cout << list- >info << “ “ << ptr - >info << “ “; ptr = ptr->link; cout << ptr->info << endl; Q3) Output of the following code const int SIZE=4; class Stack { int stk[SIZE]; int top;
Image of page 2
Image of page 3
Image of page 4

You've reached the end of your free preview.

Want to read all 4 pages?

  • Fall '17
  • Tahir Iqbal

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes