Create a program that sorts an array of integers

Assignment Help Programming Languages
Reference no: EM132233489

Exercises -

5-12. Create a program that sorts an array of integers in ascending order by using a bubble sort. If you are not familiar with the bubble sort algorithm you should be able to find an explanation in just about any introductory programming text. Assume that the array is defined to be six elements as follows:

ARRAY:

.WORD 100

.WORD 74

.WORD -144

.WORD 10022

.WORD 657

.WORD -33

The bubble sort should modify the array contents, not put the result into a second array.

5-13. An array X is considered to be greater than an array Y if for every element i, X[i] > Y[i] (the arrays are assumed to be the same length). Develop a program that sets the value of ACC = 1 if X > Y and ACC = 0, otherwise. Assume for test purposes that the arrays have six elements and are defined as follows:

X: .WORD 95       Y: .WORD 35

    .WORD 1002        .WORD 102

    .WORD 233         .WORD 109

    .WORD -137        .WORD -1378

    .WORD 6332        .WORD 6332

    .WORD -33191     .WORD -33194

Try your program with a variety of other test arrays.

5-15. Develop a program that reads in an integer value from the user and then uses a binary search on a sorted array to determine if the value is stored in the array. If you are not familiar with the binary search algorithm you should be able to find an explanation in most introductory programming texts. If the value is found, the program should print to the screen "Data is found," otherwise it should print "Data not found." Include a conversational mechanism so that multiple queries can be tried. For example, if the sorted array is defined as follows:

SORTED:

.WORD -345

.WORD -98

.WORD 109

.WORD 1555

.WORD 6332

.WORD 33194

then the following is an appropriate sample output:

Enter Data: 100

Data not found

Want to continue? (1=yes,0=no): 1

Enter data: 109

Data is found

Want to continue? (1=yes,0=no): 0

Problems -

Problem 1 - Exercise 5-13 in your textbook. Your program should load into memory at address $000. Put your solution in a single text file named hw3p1.csp. Put the object code in a file named hw3p1.obj.

Problem 2 - A variant of exercise 5-12 in your textbook, with these changes: use selection sort instead of bubble sort. Do not assume that the array has only six elements. Assume that the number of elements in the array will be found at memory address $100. Assume that ARRAY begins at $101. The sorting should be done in ascending order, so that when the sorting is done, your sorted array should have the smallest value at address $101. We discussed selection sort in class last week. Your program should load into memory at address $000. Put your solution in a single text file named hw3p2.csp. Put the object code in a file named hw3p2.obj.

Problem 3 - Another variant of exercise 5-12 in your textbook, with these changes: use insertion sort instead of bubble sort. Do not assume that the array has only six elements. Assume that the number of elements in the array will be found at memory address $100. Assume that ARRAY begins at $101. The sorting should be done in ascending order, so that when the sorting is done, your sorted array should have the smallest value at address $101. Your program should load into memory at address $000. Put your solution in a single text file named hw3p3.csp. Put the object code in a file named hw3p3.obj. Here's insertion sort implemented in Python (because somebody asked for Python), borrowed from the ECS 32B textbook:

def insertionSort(alist):

for index in range(1,len(alist)):

currentvalue = alist[index]

position = index

while position>0 and alist[position-1]>currentvalue:

alist[position]=alist[position-1]

position = position-1

alist[position]=currentvalue

alist = [54,26,93,17,77,31,44,55,20]

insertionSort(alist)

print(alist)

Problem 4 - A variant of exercise 5-15 in your textbook, with these changes: Do not read an integer value from the user. Instead, find the integer value at memory address $100. Assume that the number of elements in the sorted array will be found at memory address $101. Assume that SORTED begins at $102. If the target integer is found, set the value of ACC to 1. If the target integer is not found, set the value of ACC to 0. Do not include a conversational mechanism to permit multiple queries. Do not print anything to the screen. We discussed binary search in class last week. Your program should load into memory at address $000. Put your solution in a single text file named hw3p4.csp. Put the object code in a file named hw3p4.obj.

Reference no: EM132233489

Questions Cloud

Find the percent of markup on cost : Dollars & Cents offers a sewing kit for $2.59. If the kits cost $19.80 per dozen, find the percent of markup on cost. Round to the nearest tenth of a percent.
What motivates hackers to attack computer networks : Why is understanding hacking, exploitation, vulnerabilities, and attacks critically important? What motivates hackers to attack computer networks?
Additional skills and retention and motivation of the nurses : Is there a direct correlation between additional skills and retention and motivation of the nurses?
What factors will influence the decision : Search "scholar.google" or your textbook. Discuss the technical skills required to have a CSIRT response team consisting of employees with other job duties.
Create a program that sorts an array of integers : Create a program that sorts an array of integers in ascending order by using a bubble sort. Develop a program that reads in an integer value
Find the dividend michaels pays to its preferred : Michaels Inc. preferred stock sells for $22 and has a 16% required rate of return. Find the dividend Michaels pays to its preferred shareholders.
Ethics and social responsibility : What are the characteristics and behavior of an ethical manager?
Describe the hashing security mechanism : In your initial discussion post, please describe the hashing security mechanism and how it is different from the encryption mechanism.
What you believe to be compelling vision for the future : Identify a company in the news during that last 12 months that has expressed what you believe to be a compelling vision for the future.

Reviews

len2233489

2/13/2019 1:45:28 AM

Instructions: Open the attached files and follow the instructions. I took picture of exercises from the textbook, use C whenever it asks for no python. Include all eight files (the four .csp files and the four .obj files) in your submission through Canvas. Do not compress your submissions -- no zip files, no rar files, etc. Also, do not hard-code memory addresses in your programs. Use labels and let the assembler do the work. You should write programs that can load anywhere in memory, and hard-coded addresses don't help. Compressed files and hard- coded addresses make your TAs unhappy when they're grading, and unhappy graders give lower grades than happy graders.

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

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

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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