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

  Give the steps for to build priority queue after deque

Give the steps for to build priority queue after deque

  Working with physicists that hav an inert lattice structure

working with Physicists that hav an inert lattice structure, and they use this for placing charged particles at regual spacing along a straight line

  Data structures used to organize typical file cabinet

Recognize at least two data structures which are used to organize typical file cabinet. Why do you feel it is essential to emulate these types of data structures in computer program?

  Give algorithm-correctness proof-time complexity for tree

Determine the minimum number of nodes in tree to remove so that the tree is separated into subtrees of sizes at most k. Give the algorithm, the correctness proof and the time complexity.

  Find use two-dimensional other or multidimensional array

Suppose that you are creating an app to keep track of the places that you have visited while traveling. Determine whether or not you would use a two-dimensional or other multidimensional array (choosing to use an array) for the task at hand. Provi..

  Identify the components of a tree

Familiar with the Tree data model. You're required to identify the components of a Tree using the MS Word.

  Write and design coding flow charts and models

Write and design coding flow charts and models. Design and update software database. Troubleshooting and debugging any issues that may arise.

  Explain how to determine line in o-n lg n time

Explain how to determine such a line in O(n lg n) time. Provide the O(n^2 lg n)-time algorithm to pair Ghostbusters with ghosts in such a way that no streams cross.

  Explain the fundamental concepts of cryptographic algorithms

Explain the fundamental concepts of cryptographic algorithms. Examine malicious activities that may affect the security of a computer program and justify the choice of various controls to mitigate threats.

  Draw the binary tree of the given order

A preorder traversal of a binary tree produced AD F G H K L P Q R W Z, and an in order traversal produced G F H K D LAW R Q P Z. Draw the binary tree.

  C++ program to evaluate expressions combining set union

Create a C++ program to evaluate expressions combining set union, set intersection and parentheses

  Universalist rationality theory

Universalist rationality theory supposes that actors within an institution are rational. They function with their own material interests in mind, maximizing efficiency and resources.

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