Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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).

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92822534

Have any Question?


Related Questions in Computer Engineering

Study the information given below and answer the

Study the information given below, and answer the questions. For a long time, the Royal Victoria Hospital (RVH) worked with an information system that consisted of a mix of paper-based files and small independent databas ...

Subject oop javaassume you want to develop an application

Subject: OOP, Java Assume you want to develop an application like Microsoft Word, Microsoft Excel, Microsoft Paint, etc. in which multiple users are allowed to access the same file simultaneously from different locations ...

Question suppose we have virtual memory containing 32 pages

Question : Suppose we have virtual memory containing 32 pages with 512 bytes per page and physical memory with 16 page frames. How long is a virtual address? How long is a physical address?

The gravitational attraction between any two objects in the

The gravitational attraction between any two objects in the universe is given by the following formula: Force of Gravity = (G * m * n) / r 2 Where  m  and  n  are masses of the objects in kilograms,  r  is the distance b ...

Espn pays the nfl 11 billion per year for 8 yrs for the

ESPN pays the NFL $1.1 Billion per year for 8 yrs for the right to exclusively televise football. What is the NPV of the investment if the parent Disney CO has an opportunity interest rate that is equal to the cost of ca ...

Recall the definition of a complete graph kn is a graph

Recall the definition of a complete graph K_n is a graph with n vertices such that every vertex is connected to every oilier vertex. Recall also that a clique is a complete subset of some graph. The graph coloring proble ...

Switches are an integral part of networks they are the

Switches are an integral part of networks. They are the devices you utilize for host connectivity to the network. Please identify and discuss an attack that takes advantage of a weakness in switches.

A random sample ofnbsp77nbspeighth gradenbspstudents scores

A random sample of 77 eighth grade? students' scores on a national mathematics assessment test has a mean score of 285. This test result prompts a state school administrator to declare that the mean score for the? state' ...

A club consists of 10 seniors 12 juniors and 15 sophomores

A club consists of 10 seniors, 12 juniors, and 15 sophomores. An organizing committee of size 5 is chosen randomly (with all subsets of size 5 likely). Find the probability that the committee has at least one representat ...

You are given a test to enter graduate school you must

You are given a test to enter graduate school. You must select 10 of the 13 essay questions to answer to determine your writing skills. How many ways can you select those questions?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As