Lists, Stacks, and Queues

  

Overview: For problems 1(a) and 2(a) of this assignment, you will need a C++ compiler. In orderto receive credit, your programs must compile and run; and you must provide the actual source code file so that I can compile and run your programs (e.g. files ending in .cpp). The remaining problems for the assignment must be written up within a single Microsoft Word document file. You must include your name and course number within all files that you submit, including source code files as a comment at the top of each file that you create or modify.Problem 1. [5 points] Arrays and Linked Lists: Read the assigned chapters and notes for Module3 located in the Learning Activities area. Then provide solutions to the following:(a) [3 points] Download the List.zip file then modify the file to implement details for the helper function called createUnion(). The prototype for this function is as follows:template void createUnion(list &results, list L1, list L2);The implementation will use the C++ Standard Template Library list implementation. The print() function provides an example. The createUnion() function will create the unionof two given lists (L1 and L2) and will place the results in a third list called results. The union of two lists will consist of all items in both lists.[img width=”581″ height=”132″ src=”file:///C:Users???AppDataLocalTempksohtmlwps69D1.tmp.png”>Hint: You only need to modify the areas of the code in the List.cpp file that are markedwith the TODO comments. Everything else should remain that same. You can implement this function anyway you like, but you must use the provided lists and function signature and the list STL library. The results of the union must be placed in the results list. The print() function provides an example on how to use a for-loop with an iterator for apassed in list parameter. Note that the order of the displayed results list does not matter as long as the correct items are in the results list.[img width=”581″ height=”194″ src=”file:///C:Users???AppDataLocalTempksohtmlwps69D2.tmp.png”>Start by setting the results list equal to the first list:results = L1;This ensures that all items in first list are in the results list. Next create a for-loop and add all of the items in the second list to the results list.Output: An example of the output for the program after the function is implemented is asfollows:

1

Don't use plagiarized sources. Get Your Custom Essay on
Lists, Stacks, and Queues
Just from $13/Page
Order Essay

List 1:606920599945List 2:463741219273The union ofList 1 with List 2 is:606920599945463741219273** Press anykey to continue **(b) [2 points] Consider a function called deleteItemAtPosition(int position) in an array-based list data structure. The purpose of this method is to delete an item at the given position, if the items is in the list. This methods works fine for small array-based lists, but is very inefficient for large lists. Briefly explain why the same function is more efficient when implemented using a linked list implementation that uses pointers.Problem 2. [5 points] Stacks and Queues: Read the assigned chapters and notes for Module 4located in the Learning Activities area, then provide solutions to the following:(a) [3 points] Download the file Queue.zip and modify the Queue.cpp file by implementing the details for the helper function called addToFront(), which will take the in a queue and an item as parameters, and will add the item to the front of the queue. The remaining items in the queue will remain unchanged. The prototype for this function is as follows:template void addToFront(queue &Q, Object item);[img width=”581″ height=”165″ src=”file:///C:Users???AppDataLocalTempksohtmlwps69E3.tmp.png”>Hint: Again, you only need to modify the areas in the Queue.cpp file by adding thenecessary code to implement the TODO areas as noted in the comments. The prototype for the function and everything else in the program will remain unchanged. You must use the function signature for your implementation. Consider using another queue called results to hold the results as you are processing the items in the queue:queue results;Start by adding the passed in item to the results queue by calling results.push(item). Then walk through the queue, which is the passed in Q variable using a while loop like the one in the print() function. If the tmpItem does not equal the passed in item, add the tmpItem to the queue by calling the push() function on the results queue. Before returningfrom function set Q equal to the results queue:[img width=”581″ height=”209″ src=”file:///C:Users???AppDataLocalTempksohtmlwps69E4.tmp.png”>Q = results;Output: The output for the program after the function is implemented should appear asfollows:Queue:68.42 12.15 20.51 17.28 86.88

2

Queue after moving item 4 to front: 17.4 68.42 12.15 20.51 17.28 86.88Queue after moving item 2 to front: 20.51 17.4 68.42 12.15 17.28 86.88Queue after moving item 3 to front:13.7 20.51 17.4 68.42 12.15 17.28 86.88* Press any key to continue **(b) [2 points> Suppose you were required to implement a function called orderQueue() that takes in a queue and reorders its items in ascending order. Explain why this function would violate the original purpose and design for a queue data structure and even a priority queue data structure.Other Notes: Submit your solutions using the Problem Set 2 link provided in the Assignmentsarea. If you are using the Visual C++ or Dev-C++ compiler, you should only submit the source code files for your program (e.g. the files ending in .cpp). For space reasons, please do not submit the entire Visual C++ or Dev-C++ project folders. Do not hesitate to ask if you have any questions or need clarification on what to do for this assignment.List.zip Queue.zip PS2(1).pdf.doc
ps2_1_.pdf

list.zip

queue.zip

ps2_1_.pdf.doc

ps2_1_.pdf.doc

ps2_1_.pdf.doc

Unformatted Attachment Preview

Problem Set 2: Lists, Stacks, and Queues
CS3330 Data Structures and Algorithms
Term 5 2015: May 25 – July 26
Dr. Jack Davault
Overview: For problems 1(a) and 2(a) of this assignment, you will need a C++ compiler. In order
to receive credit, your programs must compile and run; and you must provide the actual source
code file so that I can compile and run your programs (e.g. files ending in .cpp). The remaining
problems for the assignment must be written up within a single Microsoft Word document file.
You must include your name and course number within all files that you submit, including source
code files as a comment at the top of each file that you create or modify.
Problem 1. [5 points] Arrays and Linked Lists: Read the assigned chapters and notes for Module
3 located in the Learning Activities area. Then provide solutions to the following:
(a) [3 points] Download the List.zip file then modify the file to implement details for the
helper function called createUnion(). The prototype for this function is as follows:
template
void createUnion(list &results,
list L1,
list L2);
The implementation will use the C++ Standard Template Library list implementation. The
print() function provides an example. The createUnion() function will create the union
of two given lists (L1 and L2) and will place the results in a third list called results. The
union of two lists will consist of all items in both lists.
Hint: You only need to modify the areas of the code in the List.cpp file that are marked
with the TODO comments. Everything else should remain that same. You can implement
this function anyway you like, but you must use the provided lists and function signature
and the list STL library. The results of the union must be placed in the results list. The
print() function provides an example on how to use a for-loop with an iterator for a
passed in list parameter. Note that the order of the displayed results list does not matter as
long as the correct items are in the results list.
Start by setting the results list equal to the first list:
results = L1;
This ensures that all items in first list are in the results list. Next create a for-loop and add
all of the items in the second list to the results list.
Output: An example of the output for the program after the function is implemented is as
follows:
1
List 1:
60 69 20 59 99 45
List 2:
46 37 41 21 92 73
The union of List 1 with List 2 is:
60 69 20 59 99 45 46 37 41 21 92 73
** Press any key to continue **
(b) [2 points] Consider a function called deleteItemAtPosition(int position) in an
array-based list data structure. The purpose of this method is to delete an item at the given
position, if the items is in the list. This methods works fine for small array-based lists, but
is very inefficient for large lists. Briefly explain why the same function is more efficient
when implemented using a linked list implementation that uses pointers.
Problem 2. [5 points] Stacks and Queues: Read the assigned chapters and notes for Module 4
located in the Learning Activities area, then provide solutions to the following:
(a) [3 points] Download the file Queue.zip and modify the Queue.cpp file by implementing
the details for the helper function called addToFront(), which will take the in a queue and
an item as parameters, and will add the item to the front of the queue. The remaining items
in the queue will remain unchanged. The prototype for this function is as follows:
template
void addToFront(queue &Q,
Object item);
Hint: Again, you only need to modify the areas in the Queue.cpp file by adding the
necessary code to implement the TODO areas as noted in the comments. The prototype for
the function and everything else in the program will remain unchanged. You must use the
function signature for your implementation. Consider using another queue called results to
hold the results as you are processing the items in the queue:
queue results;
Start by adding the passed in item to the results queue by calling results.push(item).
Then walk through the queue, which is the passed in Q variable using a while loop like the
one in the print() function. If the tmpItem does not equal the passed in item, add the
tmpItem to the queue by calling the push() function on the results queue. Before returning
from function set Q equal to the results queue:
Q = results;
Output: The output for the program after the function is implemented should appear as
follows:
Queue:
68.42 12.15 20.51 17.28 86.88
2
Queue after moving item 4 to front:
17.4 68.42 12.15 20.51 17.28 86.88
Queue after moving item 2 to front:
20.51 17.4 68.42 12.15 17.28 86.88
Queue after moving item 3 to front:
13.7 20.51 17.4 68.42 12.15 17.28 86.88
** Press any key to continue **
(b) [2 points] Suppose you were required to implement a function called orderQueue() that
takes in a queue and reorders its items in ascending order. Explain why this function would
violate the original purpose and design for a queue data structure and even a priority queue
data structure.
Other Notes: Submit your solutions using the Problem Set 2 link provided in the Assignments
area. If you are using the Visual C++ or Dev-C++ compiler, you should only submit the source
code files for your program (e.g. the files ending in .cpp). For space reasons, please do not submit
the entire Visual C++ or Dev-C++ project folders. Do not hesitate to ask if you have any questions
or need clarification on what to do for this assignment.
3
Overview: For problems 1(a) and 2(a) of this assignment, you will need a C++ compiler. In
order to receive credit, your programs must compile and run; and you must provide the actual
source code file so that I can compile and run your programs (e.g. files ending in .cpp). The
remaining problems for the assignment must be written up within a single Microsoft Word
document file. You must include your name and course number within all files that you submit,
including source code files as a comment at the top of each file that you create or modify.
Problem 1. [5 points] Arrays and Linked Lists: Read the assigned chapters and notes for
Module 3 located in the Learning Activities area. Then provide solutions to the following:
(a) [3 points] Download the List.zip file then modify the file to implement details for the
helper function called createUnion(). The prototype for this function is as follows:
template
void createUnion(list &results,
list L1,
list L2);
The implementation will use the C++ Standard Template Library list implementation.
The print() function provides an example. The createUnion() function will create the
union of two given lists (L1 and L2) and will place the results in a third list called
results. The union of two lists will consist of all items in both lists.
Hint: You only need to modify the areas of the code in the List.cpp file that are marked
with the TODO comments. Everything else should remain that same. You can implement
this function anyway you like, but you must use the provided lists and function signature
and the list STL library. The results of the union must be placed in the results list. The
print() function provides an example on how to use a for-loop with an iterator for a
passed in list parameter. Note that the order of the displayed results list does not matter as
long as the correct items are in the results list.
Start by setting the results list equal to the first list:
results = L1;
This ensures that all items in first list are in the results list. Next create a for-loop and add
all of the items in the second list to the results list.
Output: An example of the output for the program after the function is implemented is as
follows:
1
List 1:
60 69 20 59 99 45
List 2:
46 37 41 21 92 73
The union of List 1 with List 2 is:
60 69 20 59 99 45 46 37 41 21 92 73
** Press any key to continue **
(b) [2 points] Consider a function called deleteItemAtPosition(int position) in an arraybased list data structure. The purpose of this method is to delete an item at the given
position, if the items is in the list. This methods works fine for small array-based lists, but
is very inefficient for large lists. Briefly explain why the same function is more efficient
when implemented using a linked list implementation that uses pointers.
Problem 2. [5 points] Stacks and Queues: Read the assigned chapters and notes for Module 4
located in the Learning Activities area, then provide solutions to the following:
(a) [3 points] Download the file Queue.zip and modify the Queue.cpp file by implementing
the details for the helper function called addToFront(), which will take the in a queue
and an item as parameters, and will add the item to the front of the queue. The remaining
items in the queue will remain unchanged. The prototype for this function is as follows:
template
void addToFront(queue &Q,
Object item);
Hint: Again, you only need to modify the areas in the Queue.cpp file by adding the
necessary code to implement the TODO areas as noted in the comments. The prototype
for the function and everything else in the program will remain unchanged. You must use
the function signature for your implementation. Consider using another queue called
results to hold the results as you are processing the items in the queue:
queue results;
Start by adding the passed in item to the results queue by calling results.push(item).
Then walk through the queue, which is the passed in Q variable using a while loop like
the one in the print() function. If the tmpItem does not equal the passed in item, add the
tmpItem to the queue by calling the push() function on the results queue. Before
returning from function set Q equal to the results queue:
Q = results;
Output: The output for the program after the function is implemented should appear
as follows:
Queue:
68.42 12.15 20.51 17.28 86.88
2
Queue after moving item 4 to front:
17.4 68.42 12.15 20.51 17.28 86.88
Queue after moving item 2 to front:
20.51 17.4 68.42 12.15 17.28 86.88
Queue after moving item 3 to front:
13.7 20.51 17.4 68.42 12.15 17.28 86.88
** Press any key to continue **
(b) [2 points] Suppose you were required to implement a function called orderQueue() that
takes in a queue and reorders its items in ascending order. Explain why this function
would violate the original purpose and design for a queue data structure and even a
priority queue data structure.
Other Notes: Submit your solutions using the Problem Set 2 link provided in the Assignments
area. If you are using the Visual C++ or Dev-C++ compiler, you should only submit the source
code files for your program (e.g. the files ending in .cpp). For space reasons, please do not
submit the entire Visual C++ or Dev-C++ project folders. Do not hesitate to ask if you have any
questions or need clarification on what to do for this assignment.
3
Overview: For problems 1(a) and 2(a) of this assignment, you will need a C++ compiler. In
order to receive credit, your programs must compile and run; and you must provide the actual
source code file so that I can compile and run your programs (e.g. files ending in .cpp). The
remaining problems for the assignment must be written up within a single Microsoft Word
document file. You must include your name and course number within all files that you submit,
including source code files as a comment at the top of each file that you create or modify.
Problem 1. [5 points] Arrays and Linked Lists: Read the assigned chapters and notes for
Module 3 located in the Learning Activities area. Then provide solutions to the following:
(a) [3 points] Download the List.zip file then modify the file to implement details for the
helper function called createUnion(). The prototype for this function is as follows:
template
void createUnion(list &results,
list L1,
list L2);
The implementation will use the C++ Standard Template Library list implementation.
The print() function provides an example. The createUnion() function will create the
union of two given lists (L1 and L2) and will place the results in a third list called
results. The union of two lists will consist of all items in both lists.
Hint: You only need to modify the areas of the code in the List.cpp file that are marked
with the TODO comments. Everything else should remain that same. You can implement
this function anyway you like, but you must use the provided lists and function signature
and the list STL library. The results of the union must be placed in the results list. The
print() function provides an example on how to use a for-loop with an iterator for a
passed in list parameter. Note that the order of the displayed results list does not matter as
long as the correct items are in the results list.
Start by setting the results list equal to the first list:
results = L1;
This ensures that all items in first list are in the results list. Next create a for-loop and add
all of the items in the second list to the results list.
Output: An example of the output for the program after the function is implemented is as
follows:
1
List 1:
60 69 20 59 99 45
List 2:
46 37 41 21 92 73
The union of List 1 with List 2 is:
60 69 20 59 99 45 46 37 41 21 92 73
** Press any key to continue **
(b) [2 points] Consider a function called deleteItemAtPosition(int position) in an arraybased list data structure. The purpose of this method is to delete an item at the given
position, if the items is in the list. This methods works fine for small array-based lists, but
is very inefficient for large lists. Briefly explain why the same function is more efficient
when implemented using a linked list implementation that uses pointers.
Problem 2. [5 points] Stacks and Queues: Read the assigned chapters and notes for Module 4
located in the Learning Activities area, then provide solutions to the following:
(a) [3 points] Download the file Queue.zip and modify the Queue.cpp file by implementing
the details for the helper function called addToFront(), which will take the in a queue
and an item as parameters, and will add the item to the front of the queue. The remaining
items in the queue will remain unchanged. The prototype for this function is as follows:
template
void addToFront(queue &Q,
Object item);
Hint: Again, you only need to modify the areas in the Queue.cpp file by adding the
necessary code to implement the TODO areas as noted in the comments. The prototype
for the function and everything else in the program will remain unchanged. You must use
the function signature for your implementation. Consider using another queue called
results to hold the results as you are processing the items in the queue:
queue results;
Start by adding the passed in item to the results queue by calling results.push(item).
Then walk through the queue, which is the passed in Q variable using a while loop like
the one in the print() function. If the tmpItem does not equal the passed in item, add the
tmpItem to the queue by calling the push() function on the results queue. Before
returning from function set Q equal to the results queue:
Q = results;
Output: The output for the program after the function is implemented should appear
as follows:
Queue:
68.42 12.15 20.51 17.28 86.88
2
Queue after moving item 4 to front:
17.4 68.42 12.15 20.51 17.28 86.88
Queue after moving item 2 to front:
20.51 17.4 68.42 12.15 17.28 86.88
Queue after moving item 3 to front:
13.7 20.51 17.4 68.42 12.15 17.28 86.88
** Press any key to continue **
(b) [2 points] Suppose you were required to implement a function called orderQueue() that
takes in a queue and reorders its items in ascending order. Explain why this function
would violate the original purpose and design for a queue data structure and even a
priority queue data structure.
Other Notes: Submit your solutions using the Problem Set 2 link provided in the Assignments
area. If you are using the Visual C++ or Dev-C++ compiler, you should only submit the source
code files for your program (e.g. the files ending in .cpp). For space reasons, please do not
submit the entire Visual C++ or Dev-C++ project folders. Do not hesitate to ask if you have any
questions or need clarification on what to do for this assignment.
3
Overview: For problems 1(a) and 2(a) of this assignment, you will need a C++ compiler. In
order to receive credit, your programs must compile and run; and you must provide the actual
source code file so that I can compile and run your programs (e.g. files ending in .cpp). The
remaining problems for the assignment must be written up within a single Microsoft Word
document file. You must include your name and course number within all files that you submit,
including source code files as a comment at the top of each file that you create or modify.
Problem 1. [5 points] Arrays and Linked Lists: Read the assigned chapters and notes for
Module 3 located in the Learning Activities area. Then provide solutions to the following:
(a) [3 points] Download the List.zip file then modify the file to implement details for the
helper function called createUnion(). The prototype for this function is as follows:
template
void createUnion(list &results,
list L1,
list L2);
The implementation will use the C++ Standard Template Library list implementation.
The print() function provides an example. The createUnion() function will create the
union of two given lists (L1 and L2) and will place the results in a third list called
results. The union of two lists will consist of all items in both lists.
Hint: You only need to modify the areas of the code in the List.cpp file that are marked
with the TODO comments. Everything else should remain that same. You can implement
this function anyway you like, but you must use the provided lists and function signature
and the list STL library. The results of the union must be placed in the results list. The
print() function provides an example on how to use a for-loop with an iterator for a
passed in list parameter. Note that the order of the displayed results list does not matter as
long as the correct items are in the results list.
Start by setting the results list equal to the first list:
results = L1;
This ensures that all items in first list are in the results list. Next create a for-loop and add
all of the items in the second list to the results list.
Output: An example of the output for the program after the function is implemented is as
follows:
1
List 1:
60 69 20 59 99 45
List 2:
46 37 41 21 92 73
The union of List 1 with List 2 is:
60 69 20 59 99 45 46 37 41 21 92 73
** Press any key to continue **
(b) [2 points] Consider a function called deleteItemAtPosition(int position) in an arraybased list data structure. The purpose of this method is to delete an item at the given
position, if the items is in the list. This methods works fine for small array-based lists, but
is very inefficient for large lists. Briefly explain why the same function is more efficient
when implemented using a linked list implementation that uses pointers.
Problem 2. [5 points] Stacks and Queues: Read the assigned chapters and notes for Module 4
located in the Learning Activities area, then provide solutions to the following:
(a) [3 points] Download the file Queue.zip and modify the Queue.cpp file by implementing
the details for the helper function called addToFront(), which will take the in a queue
and an item as parameters, and will add the item to the front of the queue. The remaining
items in the queue will remain unchanged. The prototype for this function is as follows:
template
void addToFront(queue &Q,
Object item);
Hint: Again, you only need to modify the areas in the Queue.cpp file by adding the
necessary code to implement the TODO areas as noted in …
Purchase answer to see full
attachment

  
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more