cs301 2ns assignment

Assignments ,Quiz, Solved GDB

Moderator: abdulsaboor

cs301 2ns assignment

Postby sameea » Sat Apr 28, 2012 12:08 pm

Assignment No. 02
SEMESTER Spring 2012
CS301- Data Structures
Total Marks: 20

Due Date: April 30, 2012
Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (zero marks) if:
o The assignment is submitted after due date.
o The submitted code does NOT compile.
o The submitted assignment is other than .CPP file.
o The submitted assignment does NOT open or file is corrupted.
o The assignment is copied (from other student or ditto copy from handouts or internet).
Uploading instructions
For clarity and simplicity, You are required to Upload/Submit only ONE .CPP file.

Note: Use ONLY Dev-C++ IDE.
Objective
The objective of this assignment is

o To make you familiar with Programming the Tree Data Structure.

For any query about the assignment, contact at cs301@vu.edu.pk
GOOD LUCK

Assignment Statement: Marks: 20

Suppose some VU campuses are connected to a central server placed at Lahore campus via leased lines such that each campus has a one hop (direct) connectivity to the central server or it has multi hop connection to Lahore campus via other campuses at provincial head quarters or regional campuses which are in turn connected to the Lahore Campus.
Here is a table showing campus names and assumed codes.

Campus Code
Lahore 18
Islamabad 95
Rawalpindi 29
Peshawar 41
Fateh Jang 52
Chakwal 74
Karachi 86
Haiderabad 33
Quetta 57
Badeen 20
Zob 17


Below is the Binary Tree showing the leased line spanning in which each node contains one campus code while the edges show the direct connectivity between two campuses.




















Write a C++ program to store this Binary Tree in computer memory in which each node has the campus code as value (campus name storing is excluded for the sake of simplicity).
Also print on screen, the post order traversal of stored binary tree in order to verify your solution.

Solution Guidelines:
• In coding there must be a class to create and manipulate tree nodes.
• There should be a function to create (store) this binary tree from two of its traversals given below.
• In main( ) function, use two arrays to store Preorder and Inorder traversals of the given binary tree.

Hint:
Use Preorder and Inorder Traversals of the Binary Tree for solving.

Write on paper, a manual Postorder traversal of the tree to see your screen printed Postorder traversal with it, for verification of your solution correctness.

[Preorder: 18 95 41 29 52 74 86 33 57 17 20]
[Inorder: 41 95 74 52 29 18 86 57 17 33 20]




Lectures Covered: This assignment covers Lecture # 11-16
Deadline: Your assignment must be uploaded/submitted at or before April 30, 2012
sameea
Visitor
Visitor
 
Posts: 30
Joined: Tue Oct 25, 2011 10:47 am

Return to VU STUDENTS FORUM

Who is online

Users browsing this forum: No registered users and 9 guests
cron