Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Subject Passing array as argument allow the function to modify argument array. Pointer notion in place of array index notation Specification Write an ANSI-C program
Subject Passing array as argument allow the function to modify argument array. Pointer notion in place of array index notation Specification Write an ANSI-C program that reads inputs line by line, and sorts each line of input alphabetically, according to the indexes of the characters in ASCII table, in ascending order. That is, the letter that appear earlier in the ASCII table should appear earlier in the sorted array. The program terminates when quit is read in Implementation Assume that each line of input contains at most 30 characters and may contain blanks Use fgets to read line by line Define a function void sortArray (char *) which sorts characters in the argument array according to the index in the ASCII table Do not use extra arrays. sortArry should sort and modify the argument array directly Do not use array indexing [] throughout the program, except for array declarations in main Instead, use pointers and pointer arithmetic to manipulate arrays Do not use global variables. People have been investigating sorting problems for centuries and there exist various sorting algorithms, so don't try to invent a new one. Instead, you can implement any one of the existing sorting algorithms, e.g., Bubble Sort, Insertion Sort, Selection Sort. (Compared against other sorting algorithms such as Quick Sort, Merge Sort, these algorithms are simpler but slower (n2) complexity). Pseudo-code for Selection Sort is given below for you SELECTION-SORT(A) 0. n number of elements in A 1. for i-0 to n-1 2. 3. 4 smallest-i I/ smallest: index of current smallest, initially i forj-i+ to n ifA[j ]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started