Implement the application using a singly linked list

Assignment Help JAVA Programming
Reference no: EM135157

Q1.

Write a program called "LinearStringSearch.java" that looks for a target string value in an array of string values. Initialize the array with 10 random strings. The target string should be searched from the beginning of the array to the end of the array. Then, modify the algorithm so that after completing the first search from the beginning of the array to the end, a "second search" for the string in the array is conducted, except that the second search starts from the end of the array and moves towards the beginning of the array. 

Print on console, using the index of the target string, which of the two, the beginning-to-end or the end-to-beginning search, found the target string quicker. Ignore outcomes if the target string is not found in the array.  

Assuming that statistics on these two types of searches for the last 1000 runs are made available, discuss whether it is advantageous or not to use the statistics to opt one type of search over the other. For example, the statistics could indicate that out of 1000 search runs, 780 runs produced faster results when searching from end to beginning. Modify the program to include this particular functionality so that 

a)  the algorithm either searches beginning-to-end or end-to-beginning depending on this statistic 

b)  the algorithm updates the statistic using the outcome of the current search - that is, if the current search is faster for an end-to-beginning search, then increment the statistic by 1 to 781; else decrement the statistic by 1 to 779.

Q2.

Cattell-Horn-Carroll's theory attempts to measure intelligence quotient (IQ) in terms of the ten factors listed below. These ten factors take on different values. The IQ is calculated as a sum of the values of the ten factors. Write a Java program to input, calculate, and print the IQ of a person based on this theory. 

- Fluid intelligence (Gf): the broad ability to reason, form concepts, and solve problems using unfamiliar information or novel procedures. 

Input the Gf value interactively from the console. The value of Gf ranges from 1 to 15. 

- Crystallized intelligence (Gc): the breadth and depth of a person's acquired knowledge, the ability to communicate one's knowledge, and the ability to reason using previously learned experiences or procedures. 

Possible values of Gc are 'excellent', 'acceptable', and 'poor'. The value of Gc (excellent, acceptable, or poor) is known and should be encoded in the program by default. if excellent, gc contributes a value of 15 to iq; if acceptable, Gc contributes a value of 8 to IQ; and if poor, Gc contributes a value of 3 to IQ.

 - Quantitative reasoning (Gq): the ability to comprehend quantitative concepts and relationships and to manipulate numerical symbols. 

The value of Gq is 'true' or 'false', and is to be input interactively from the console. If true, Gq contributes a value of 10 to IQ; if false, Gq does not contribute to IQ at all.

- Reading and writing ability (Grw): basic reading and writing skills. 

Possible values of Grw are 'brilliant', 'good', 'normal', and 'poor'. The value of Grw is known and should be encoded in the program by default. If brilliant, Grw contributes a value of 15 to IQ; if good, Grw contributes a value of 10 to IQ; if normal, Grw contributes a value of 6 to IQ; if poor, Grw contributes a value of 2 to IQ. 

- Short-term memory (Gsm): the ability to apprehend and hold information in immediate awareness and then use it within a few seconds. 

Possible values of Gsm are 'good' and 'bad'. Input Gsm values interactively from the console. If good, Gsm contributes a value of 15 to IQ; if bad, Gsm contributes a value of 5 to IQ.

 - Long-term storage and retrieval (Glr): the ability to store information and fluently retrieve it later in the process of thinking. 

The values of Glr are in the range of 1 to 15. The value of Glr is known and should be encoded in the program by default. 

- Visual processing (Gv): the ability to perceive, analyze, synthesize, and think with visual patterns, including the ability to store and recall visual representations. 

The values of Gv are in the range of 1 to 10. The value of Gv is known and should be encoded in the program by default. 

- Auditory processing (Ga): the ability to analyze, synthesize, and discriminate auditory stimuli, including the ability to process and discriminate speech sounds that may be presented under distorted conditions. 

The values of Ga are in the range of 1 to 5. Input the Ga value interactively from the console.

 - Processing speed (Gs): the ability to perform automatic cognitive tasks, particularly when measured under pressure to maintain focused attention. 

Gs can be calculated as a relation to the person's age. The age should be input interactively from the console. The age is in the range from 21 to 75. Gs is calculated using the formulation [100 - age] / 10.

 - Decision/reaction time/speed (Gt): reflect the immediacy with which an individual can react to stimuli or a task. Gt is a function Gs and is calculated by the formula: [10 - Gs].

Q3.

An alternative to bubble sort is bi-directional bubble sort where the algorithm compares each adjacent pair of elements in the input array. The values are swapped as per the comparison function. Bi-directional bubble sort is also known as cocktail shaker sort, shaker sort, or double-direction bubble sort. Given below is a piece of implementation of the same.

public class ShakerSort {

   public static void ShakerSort(int[] a) {

      for (int p = 1; p <= a.length / 2; p++) {  // phase p of Shaker sort

         // first do left-to-right bubbling pass

         for (int i = p - 1; i < a.length - p; i++)

            if (a[i] < (a[i+1]))

               myswap(a, i, i + 1);

           // now do right-to-left bubbling pass

         for (int i = a.length - p - 1; i >= p; i--)

            if (a[i] < (a[i-1]) < 0)

               myswap(a, i, i - 1);

      }

   }

}

 Suppose we are to sort the elements [6,5,2,8,3,1]. The number of phases is computed as 3 (as per the code above). In the left to right bubbling pass of the first phase, the pair (6,5) is compared and swapped to get the array [5,6,2,8,3,1]. Next the pair (6,2) is compared and swapped to get [5,2,6,8,3,1]. The next comparison (6,8) causes no swap. When 8 and 3 are compared, a swap is done to get [5,2,6,3,8,1]. The final comparison of this pass is (8,1). Following the swap, we get [5,2,6,3,1,8]. Now the right-to-left pass begins. The pair (3,1) is compared first, a swap is done, and we get the array [5,2,6,1,3,8]. Next the pair (6,1) is compared, and we get [5,2,1,6,3,8]. At the end of the right-to-left pass we have [1,5,2,6,3,8]. Phase 2 works on the segment [5,2,6,3]. After the left-to-right pass, we have [2,5,3,6]; and after the right-to-left pass, we have [2,3,5,6]. The third phase works on the segment [3,5].

 Suppose we start with an array a[0: n-1] of elements to be sorted. After the left-to-right bubbling pass of phase 1, the largest element is in the rightmost position. So the right-to-left pass needs to be concerned only with elements in positions 0 through n-2 of the array. Following the right-to-left pass, the smallest element is in position 0 of the array.

Consequently, the next phase needs to be concerned only with the elements in positions 1 through n-2.

 In general, the left-to-right pass of phase p of shaker sort needs to be concerned only with elements in positions p-1 through n-p, and the right-to-left pass of this phase needs to be concerned only with elements in positions n-p-1 through p. 

Use the code given above to develop the program as "ShakerSort.java" and identify its complexity. Discuss its advantages compared to a regular bubble sort. What happens when n is odd?

Q4.

Implement the following application using a singly linked list. This application accepts from console and stores a list of 10 names (first name followed by last name) of your friends in the singly linked list. The order of arrival of these names determines the sequence of names in the linked list.

Implement a method that sorts the original sequence into a new sequence based on the alphabetical order of the last names. Modify the program using a doubly-linked list data structure, and add a method that searches for the first name of a friend.  

Finally, discuss what would happen when you link the last entry in the list with the first entry of the list.

Reference no: EM135157

Questions Cloud

Evaluate the use of complex models of project risk : Critically analyse the concept of risk; discuss how it can be measured and ranked and outline how a project risk management strategy may be constructed.
Implement a card game in java : In this assignment, you will be asked to implement a card game. You will need to make several design decisions for your code. It will be expected that all classes you write will utilize the principle of encapsulation.
Prepare a web application for internet service provider : Prepare a Web application and write the code also event planning document base. This web application allows the user to sign up for an Internet service provider for home connectivity.
Prepare address book java application : Prepare an application that reads the contents of your address book file and prepare a user guide that includes a description of the functionality of your overall address book system.
Implement the application using a singly linked list : Implement the following application using a singly linked list. This application accepts from console and stores a list of 10 names of your friends in the singly linked list
Review the cohan case study : Explain the relationship between power, politics and conflict at Enron. Explain how HRM approaches could have been utilised to assist employees through conflict resolution and why.
Hrm consultancy report : What organisational issues might the scenario transition create and what are the people management implications of this transition? What HRM approaches may need to be revised and/or new ones introduced?
Importance of training to expatriates : The aim of this paper, from this perspective is to reflect on various cultural theories and the impact of the same on organizations. In addition, this report addresses multi-national companies and the role of expatriates.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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