Write a console application with an Algorithm class

Assignment Help Data Structure & Algorithms
Reference no: EM132306149

Algorithms and Data Structures Assignment - Sorting and Searching

Learning Outcomes - Implement common data structures and algorithms.

Question 1 -

SETUP - for this entire assignment;

You are required to write a console application with an Algorithm class.

This class should contain a Numbers array which contains 50 integer elements.

These elements are to be generated at random.

You are to write a Display method, which will display the contents of this array to the screen.

Add the appropriate code to Main, so the numbers are displayed.

The particular challenge for this question is to then add a findMaximum method to your program that will receive two parameters:

  • an array
  • an integer (n = number of maximum elements to be found)

This method has the job of displaying the n largest elements in the array it receives and displaying it to the screen as shown in the sample program attached.

NOTE: Do not use the array sort method to complete this challenge.

Question 2 -

When using a sequential search algorithm (such as linear) to find a value, it will always find the first occurrence of that item in the array.

For example consider an array intArray with values 2, 4, 8, 6, 18, 4, 9, 4, 3.

If the user wanted to search for the number 4 in the array, a sequential search algorithm will return the first occurrence of 4 (that is at index 1 in the intArray).

For this question you are required to extend the program and class created in question 1 by adding a NumOccuranceSearch method, which is a modified sequential search that receives three parameters:

  • an array
  • an integer (the value the user wants to search for i.e. 4)
  • and a second integer (the occurrence of the item they want to search for i.e. 2nd).

The method is to display the index of the occurrence of that number to the screen as shown in the sample program attached.

Question 3 -

For this question you are required to extend the program and class even further by adding a LastOccuranceSearch method, which finds the last occurrence of the searched item.

The method should receive two parameters:

  • an array
  • an integer (the value the user wants to search for i.e. 4)

And return the index of the last occurrence to Main, so it can be displayed.

Question 4 -

As you know the bubble sort algorithm isn't the fastest method for sorting data, but it could be improved.

The challenge for this question is to look at improving the bubble sort. Consider the following:

You will notice after the first pass of the algorithm the highest number is "in place", after the second pass the two highest numbers are "in place" and so on. Consider as the array elements are moved so the highest numbers in place, do we need to continue to make 49 passes of a 50 element array? Or can this be reduced?

For this question you are required to extend your program and class again by adding the following two methods:

  • bubbleSort ()
  • improvedBubbleSort ()

The bubbleSort () method will implement the standard bubble sort algorithm and time how long the takes to sort the values in your array.

The improvedBubbleSort () method will implement the following two improvements and time how long it takes to sort the same data:

1. Modify the algorithm so instead of making 49 comparisons on every pass of a 50 element array, it will now make 48 comparisons on the second pass, 47 on the third pass and so on.

2. Also modify the algorithm to check at the end of each pass whether any swaps have been made. If none have been made, the data must already be in the proper order, so the algorithm should terminate.

Both methods should output the resulting times to the screen to see if any improvement in times has been achieved.

Attachment:- Assignment File.rar

Verified Expert

The solution programs are implemented in c#.It has four programs are find and print the maximum number from array, sequential search algorithm to find a value, it will always find the first occurrence of that item in the array, Last Occurrence Search method, which finds the last occurrence of the searched item and implemented time complexity of bubble sort and improved bubble sort program. All the above programs output screen shots and programs are attached.

Reference no: EM132306149

Questions Cloud

Are there thematic similarities shared by the songs : Compare and contrast your assigned Dylan song with one or more of the Dylan songs on our syllabus. Are there thematic similarities shared by the songs?
Power and organizational politics have changed overtime : Discuss how the views about power and organizational politics have changed overtime.
Describe the categories of change in detail : In the Essay you will be asked to trace developments in the PNW from the pre-contact period into the settlement period. In studying for the essay, make sure to.
Create memo explaining what communication means : Create a memo explaining what communication means. Make it at least two paragraphs.
Write a console application with an Algorithm class : COMP6211 Algorithms and Data Structures - Sorting and Searching, TOI OHOMAI Institute of Technology, New Zealand. Write a console application
What were the long-term effects of the industrial revolution : What impact did the invention/innovation in question have on the United States? Include 1 positive and 1 negative result of its creation.
What we submit on all digital communication : With digital world here, why is it important to review what we submit on all digital communication?
How do real events get placed into a narrative frame : How do "real" events get placed into a narrative frame? John Krakauer's Into the Wild, Ridley Scott/Mark Bowden's Blackhawk Down, or Cheryl Strayed.
The small business administration with examples : What are four different types of innovations classified by The Small Business Administration with examples?

Reviews

len2306149

5/15/2019 3:12:15 AM

Data Structure & Algorithm in c# program in Visual Studio 2015. Instructions - NOTE: This assignment is an individual assignment. It is your responsibility to clarify any aspect of the assignment that you are unsure of, with your lecturer. You are required to up a zip file with your solutions to Moodle before due date. The assignment will not be accepted using any other method.

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

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