Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CS301- Data Structures Assignment No.1 Solution Spring 2014
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#1



Total Marks: 20

Due Date:
Wednesday, May 07, 2014

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:
The assignment is submitted after due date.
The submitted code does NOT compile.
The submitted assignment file is other than .CPP format.
The submitted assignment file does not open or corrupted.
The assignment is copied (from other student or copied from handouts or internet).

Uploading instructions
Don’t wait for grace day. Grace Day is given only if there is problem with LMS on due date. Submit your solution within due date.
Note that no assignment will be accepted through email if there is any problem on grace day.

Note: Use only dev-C++ IDE.

Objective
The objective of this assignment is

To make you familiar with list data structures and programming techniques to implement list data structure by using linked list.

Question:

I am sending you a C++ program related to linked list along with your assignment file. In the given C++ program, I did not write some functions. Name of these functions are given below.

1) main()
2) List add Nodes(int number)
3) void split(int c, List list, List large List, List small List)
4) void difference List(List list A, List list B)

Your assignment is to write the codes of these functions so that given program could be compiled and run to perform the required functionality/purpose.
Moreover required functionality/purpose of this C++ program is to perform the following tasks given below by using a linked list.

Splitting up an odd list:
1) Your program should ask the user to input any number.
2) Create a linked list that will contain all the odd elements less than the number which you entered in first step. Also display this list.
3) Now ask the user to enter any pivot element. Pivot element is a simple integer number. Use this pivot element to divide the list into two halves. First half will contain all the elements smaller than that pivot element. Save this first half into a list called small List. Second half will contain all the elements larger than that pivot element. Save this second half into a list called large List.
4) Display small List and Large List that you formed in step 3.

Performing set difference operation on two odd lists:
1) Your program should ask the user to input any two integer number for example 30 and 20.
2) Create a linked list i.e. ‘list A’ that will contain all the odd elements less than the number 30 which you entered in first step. Also display this list.
3) Create a linked list i.e. ‘list B’ that will contain all the odd elements less than the number 20 which you entered in first step. Also display this list.
4) Perform the set difference operation on the two lists ‘list A’ and ‘list B’.
5) Save the result of set difference operation in another list called set Difference and then display the list set Difference.

Note:

1) Pivot element should be positive, greater than 0 and pivot element must also be from the list.



Reply
#2
I am sending you a C++ program related to linked list along with your assignment file. In the given C++ program, I did not write some functions. Name of these functions are given below.

1) main()
2) List addNodes(int number)
3) void split(int c, List list, List largeList, List smallList)
4) void differenceList(List listA, List listB)
Linked List:
#include <iostream.h>
#include <stdlib.h>

class Node
{
public:
int get() { return object; };
void set(int object) { this->object = object; };
Node * getNext() { return nextNode; };
void setNext(Node * nextNode) { this->nextNode = nextNode; };
private:
int object;
Node * nextNode;
};


class List
{
public:
List();
void add (int addObject);
int get();
bool next();
friend void traverse(List list);
friend List addNodes(int number);
friend void split(int c, List list, List largeList, List smallList);
friend void differenceList(List listA, List listB);



private:
int size;
Node * headNode;
Node * currentNode;
Node * lastCurrentNode;
};
/* Constructor */
List::List()
{
headNode = new Node();
headNode->setNext(NULL);
currentNode = NULL;
lastCurrentNode = NULL;
size = 0;
}
/* add() class method */
void List::add (int addObject)
{
Node * newNode = new Node();
newNode->set(addObject);
if( currentNode != NULL )
{
newNode->setNext(currentNode->getNext());
currentNode->setNext( newNode );
lastCurrentNode = currentNode;
currentNode = newNode;
}
else
{
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode = headNode;
currentNode = newNode;
}
size ++;
}
/* get() class method */
int List::get()
{
if (currentNode != NULL)
return currentNode->get();
}
/* next() class method */
bool List::next()
{
if (currentNode == NULL) return false;
lastCurrentNode = currentNode;
currentNode = currentNode->getNext();
if (currentNode == NULL || size == 0)
return false;
else
return true;
}
/* Friend function to traverse linked list */
void traverse(List list)
{
Node* savedCurrentNode = list.currentNode;
list.currentNode = list.headNode;
cout "\n\n Elements of list are given below ";
for(int i = 1; list.next(); i++)
{
cout "\n Element " i " " list.get();
}
cout "\n List size = " list.size '\n';
list.currentNode = savedCurrentNode;
}

void split(int c, List list, List largeList, List smallList)
{

}



List addNodes(int number)
{

}

void differenceList(List listA, List listB){

}



main()
{


}


0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Cs403 Assignment 3 Helping material May 8,2010 viki 1 5,218 04-28-2020, 03:19 PM
Last Post: ClaireBeauc
  cs301 assignment no 3 Solution 20 January 2016 Vuhelper 0 11,098 01-20-2016, 03:32 PM
Last Post: Vuhelper
  CS201 Assignment vo 3 Solution 20th January 2016 Vuhelper 2 2,612 01-20-2016, 03:28 PM
Last Post: Vuhelper
  CS101 Assignment no 3 Solution 20th January 2016 Vuhelper 0 2,292 01-20-2016, 03:25 PM
Last Post: Vuhelper
  SOC101 INTRODUCTION TO SOCIOLOGY assignment no 3 Solution 20 January 2016 Vuhelper 0 1,884 01-20-2016, 03:19 PM
Last Post: Vuhelper
  CS402 Assignment No 4 Solution & Discussion Xpert 0 2,111 08-01-2015, 02:33 AM
Last Post: Xpert
  cs101 Assignment No. 1 Solution 21 may spring 2015 semester Xpert 0 2,924 05-21-2015, 12:41 AM
Last Post: Xpert
  Assignment solution eng 301 due date 20 may 2015 rumesa khan 3 4,545 05-20-2015, 01:34 AM
Last Post: Xpert
  PHY301 Circuit Theory Assignment No. 1 idea Solution spring may 2015 semester Xpert 0 1,573 05-15-2015, 03:52 AM
Last Post: Xpert
  Assignment No. 01 Spring 2015 Information Systems CS507 idea solution spring 2015 Xpert 0 2,461 05-15-2015, 03:49 AM
Last Post: Xpert

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support