W8 - subscript operator . mytable[0][0] equal 1;...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Workshop 8 C1117a Computer Programming
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Outline Sort - Bubble Sort 2D Array Workshop Exercise
Background image of page 2
Sort Selection Sort – lecture Bubble Sort – tutorial  Insertion Sort  Merge Sort  Heap Sort  Quick Sort
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Bubble Sort A kind of exchange sort Idea:  In each iteration, comparing each pair of  adjacent items and swapping them if they  are in the wrong order.  The iterations are repeated until no swaps  are needed, which indicates that the list is  sorted. 
Background image of page 4
Bubble Sort Example: Let us take the array of numbers "5 1 4 2 8", and sort an array in ascending order using bubble sort algorithm. In each step, elements  written in bold are being compared. 
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Exercise 1 Complete the program: Bubblesort.cpp
Background image of page 6
2D Array An array of array: table. For multi-dimensional array, the declaration must  have bounds for all dimensions except the first one.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2D Array We can access the elements of 2D array by using the 
Background image of page 8
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 10
Background image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: subscript operator . mytable[0][0] equal 1; mytable[1][2] equal 2; Change values: mytable[0][0] = 7; mytable[1][1] = 9; Exercise 2 Complete the program: Matrix.cpp Multiplying an 4 4 matrix with an 4 4 matrix Matrix Multiplication Multiplying an m n matrix with an n p matrix results in an m p matrix. The element x i,j at the intersection of row i and column j of the product matrix is the dot product (inner product) of row i of the first matrix and column j of the second matrix. 1,1 1,2 1,1 1,2 1,1 1,1 1,2 2,1 1,1 1,2 1,2 2,2 2,1 2,2 2,1 2,2 2,1 1,1 2,2 2,1 2,1 1,2 2,2 2,2 a a b b a b a b a b a b a a b b a b a b a b a b + + = + + The End Submit program to web hand in system Answers:...
View Full Document

This document was uploaded on 05/04/2011.

Page1 / 11

W8 - subscript operator . mytable[0][0] equal 1;...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online