Write a main program that creates a forward linked list

Assignment Help Computer Engineering
Reference no: EM131984882

Problem

Linked Lists

Objectives

• Get yourself familiar with the forward linked list creation and operations

• Manipulate pointers

• Do NOT use any STL containers

Overview

1. We wish to maintain several stocks in a linked list. Each stock has a stock symbol (STLstring), a cost (double, i.e. purchase price), the number of shares (int). One needs apointer to the next node in the linked list. There are at least the following three approaches

• Approach 1class stockNode {string symbol; double cost; int shares; stockNode *next; };

• Approach 2class stock {string symbol; double cost; int shares; };class stockNode {stock info; stockNode *next; };

• Approach 3class stock {string symbol; double cost; int shares; };class stockNode: public stock {stockNode *next; };

Choose approach 2 or 3.

2. Write a main program (lab4Main.cpp) that creates a forward linked list of at least 10elements, where each element holds a stock, without keeping track of list length. Noneed to have a separate stockDB class. This means the main program itself is equivalentto the stockDB class. In the main program for each stock, you can hard-code a stocksymbol (or just do S1, S2, etc.), cost, and shares (or you can randomly generate any ofthese three). Alternatively, you could choose to reading a stock file, which might beeasier.

3. From the main program, print the list.

4. Write the function "returnMiddleList" in the main program to find the middle elementof the linked list in one pass.

• This function splits the input list in half at the middle element to create twoentirely separate output linked lists of near equal size (+/- 1). In other words, write the "split in half" function.

• For each of the following cases, print the two output lists

a. The input list is an empty list.

b The input list has only one element.

c The input list has odd number of elements (> 1).

Reference no: EM131984882

Questions Cloud

Create a sample cs course database using phpmyadmin : Create a sample CS course database using phpMyAdmin. You will design the database structure yourself. The table you build should show subject prefix.
How much will you have if you make deposits for 40 years : If you deposit $5,000 at the end of each of the next 20 years into an account paying 10.8 percent interest.
Calculate the required rate of return on a stock : Calculate the required rate of return on a stock that has a beta of 1.1 when the expected return on the market is 12% and the risk-free rate is 3%.
What are the factors that affect a linear regression model : What are the factors that affect a linear regression model? How can you accomplish linear regression in R?
Write a main program that creates a forward linked list : Write a main program that creates a forward linked list of at least 10elements, where each element holds a stock, without keeping track of list length.
How does the policies being made affect human beings : What is policy and what are some reasons why policies are been made. How does the policies being made affect human beings
Prove and give an example showing the variable : Prove and give an example showing that the variable that becomes basic in one iteration of the simplex method can become nonbasic in the next iteration.
Ronald reagan inherited when he became president : Within the country, we were experiencing the worst economic chaos since the Great Depression. These were the conditions that Ronald Reagan inherited.
What is the store average markup rate on cost : MATH250 Business Mathematics Final Assignment - What is the store's average markup rate on cost for these shirts

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd