Ece 175: computer programming for engineering applications

Ece 175: computer programming for engineering applications

ECE 175: Computer Programming for Engineering Applications

Homework Assignment 7

Conventions: Name your C programs as hwx py.c where x corresponds to the homework number and y corresponds

to the problem number. As an example the C program for hw1 problem 1 should be named as hw1 p1.c. Write

comments to your programs. Programs with no comments will receive PARTIAL credit. At each program you turn

in at least the following info should be included

– Author:

– Date created:

– Brief (two-line) description of the program:

Submission Instructions: Use the dropbox on D2L to submit only the .c les.

Problem 1: The les in sudoku.zip contain integer values for Sudoku puzzles (two dimensional integer arrays with

9 rows and 9 columns). Write a program that reads a sudoku le as input and prints out if the le is a proper

solution to the Sudoku puzzle.

For the rules of Sudoku, check Wikipedia: http://en.wikipedia.org/wiki/Sudoku.

Example of a correct Sudoku puzzle:

1 2 3 4 5 6 7 8 9

4 5 6 7 8 9 1 2 3

7 8 9 1 2 3 4 5 6

2 3 4 5 6 7 8 9 1

5 6 7 8 9 1 2 3 4

8 9 1 2 3 4 5 6 7

3 4 5 6 7 8 9 1 2

6 7 8 9 1 2 3 4 5

9 1 2 3 4 5 6 7 8

Problem 2: Insertion Sort is a sorting algorithm that moves the elements of an array to their correct position

one element at a time. The following example shows the steps for sorting array data= [3, 7, 4, 9, 5, 2, 6, 1]. In

each step, the item under consideration is underlined. The array before the underlined element is already sorted

while the array after the underline element is unsorted. The item that is moved (or left in place because it was the

biggest yet considered) to the correct position within the sorted part of the array. The new position of the element

that was moved in the previous step, appears in bold in the next step.

3 7 4 9 5 2 6 1

3 7 4 9 5 2 6 1

3 7 4 9 5 2 6 1

3 4 7 9 5 2 6 1

3 4 7 9 5 2 6 1

3 4 5 7 9 2 6 1

2 3 4 5 7 9 6 1

2 3 4 5 6 7 9 1

1 2 3 4 5 6 7 9

1

Develop C code that would implement the Insertion Sort algorithm. Your code should use the following functions

void insertion(int x[ ], int size)

void print ar(int x[ ], int size)

void swap(int *a, int *b)

The last two functions are already provided in the class notes.

Submit your .c les named hw7 p1.c and hw7 p2.c via D2L dropbox

2

Ece 175: computer programming for engineering applications

ad:  Delta 8 online | THC Online | Buy hemp online | THC Carts | Delta 8 Carts | THCO Carts | HQD Vape | Fume Vape | Fume Extra | Fume Unlimited | HQD Cuvie | HQD Cuvie plus | zero Nic Disposable Vapes | Fume Infinity | Fume Ultra | FoodGod | Supreme Vape 

ECE 175: Computer Programming for Engineering Applications

Homework Assignment 7

Conventions: Name your C programs as hwx py.c where x corresponds to the homework number and y corresponds

to the problem number. As an example the C program for hw1 problem 1 should be named as hw1 p1.c. Write

comments to your programs. Programs with no comments will receive PARTIAL credit. At each program you turn

in at least the following info should be included

– Author:

– Date created:

– Brief (two-line) description of the program:

Submission Instructions: Use the dropbox on D2L to submit only the .c les.

Problem 1: The les in sudoku.zip contain integer values for Sudoku puzzles (two dimensional integer arrays with

9 rows and 9 columns). Write a program that reads a sudoku le as input and prints out if the le is a proper

solution to the Sudoku puzzle.

For the rules of Sudoku, check Wikipedia: http://en.wikipedia.org/wiki/Sudoku.

Example of a correct Sudoku puzzle:

1 2 3 4 5 6 7 8 9

4 5 6 7 8 9 1 2 3

7 8 9 1 2 3 4 5 6

2 3 4 5 6 7 8 9 1

5 6 7 8 9 1 2 3 4

8 9 1 2 3 4 5 6 7

3 4 5 6 7 8 9 1 2

6 7 8 9 1 2 3 4 5

9 1 2 3 4 5 6 7 8

Problem 2: Insertion Sort is a sorting algorithm that moves the elements of an array to their correct position

one element at a time. The following example shows the steps for sorting array data= [3, 7, 4, 9, 5, 2, 6, 1]. In

each step, the item under consideration is underlined. The array before the underlined element is already sorted

while the array after the underline element is unsorted. The item that is moved (or left in place because it was the

biggest yet considered) to the correct position within the sorted part of the array. The new position of the element

that was moved in the previous step, appears in bold in the next step.

3 7 4 9 5 2 6 1

3 7 4 9 5 2 6 1

3 7 4 9 5 2 6 1

3 4 7 9 5 2 6 1

3 4 7 9 5 2 6 1

3 4 5 7 9 2 6 1

2 3 4 5 7 9 6 1

2 3 4 5 6 7 9 1

1 2 3 4 5 6 7 9

1

Develop C code that would implement the Insertion Sort algorithm. Your code should use the following functions

void insertion(int x[ ], int size)

void print ar(int x[ ], int size)

void swap(int *a, int *b)

The last two functions are already provided in the class notes.

Submit your .c les named hw7 p1.c and hw7 p2.c via D2L dropbox

2

Leave a Comment

Your email address will not be published. Required fields are marked *