Skip to content

UMK-Data-Science/week-4-basic-operations

Repository files navigation

Tutorial 4 - Basic Operations in Array

This is tutorial cover basic operations in array including traverse, insertion, deletion, search and update operations. Please answer all questions and read carefully :octocat:

Instructions

This tutorial consists with 10 questions. Try to complete this tutorial by commit your changes and read the question carefully 🚀

Exercise 1 - Traverse Operation

LA is an array where it store 10 elements of an integer as follow:

LA[] = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20};

Write a traverse operation algorithm to print all element in the array as follow:

Output: 
LA[0] = 2
LA[1] = 4
LA[2] = 6
LA[3] = 8
LA[4] = 10
LA[5] = 12
LA[6] = 14
LA[7] = 16
LA[8] = 18
LA[9] = 20

Exercise 2 - Traverse Operation

LA is an array where it stores 10 elements of an integer as follow:

LA[] = {1, 4, 5, 7, 10, 12, 13, 17, 18, 20};

Write a traverse operation algorithm to print even number from the array as follow:

Output: 
LA[1] = 4
LA[4] = 10
LA[5] = 12
LA[8] = 18
LA[9] = 20

Exercise 3 - Insertion Operation

LA is an array where it stores 5 elements of float as follow:

LA[] = {1.5, 1.2, 1.8, 1.6, 1.1};

Insert a new element with the value of 1.4 as fourth position from the array above and print the output as follow:

Output: 
LA[0] = 1.5
LA[1] = 1.2
LA[2] = 1.8
LA[3] = 1.4
LA[4] = 1.6
LA[5] = 1.1

Exercise 4 - Insertion Operation

LA is an array where it stores 4 element of vowel character as follow:

LA[] = {'a', 'e', 'i', 'o'}; 

Insert another 1 vowel character ('u') at the end of an array and print the output as follow:

Output:
LA[0] = a
LA[1] = e
LA[2] = i
LA[3] = o
LA[4] = u

Exercise 5 - Deletion Operation

LA is an array where it stores 5 elements of float as follow:

LA[] = {1.5, 1.2, 1.8, 1.6, 1.1};

Delete an element available at the third position of an array and print the output as follow:

Output:
LA[0] = 1.5
LA[1] = 1.2
LA[2] = 1.6
LA[3] = 1.1

Exercise 6 - Deletion Operation

LA is an array where it stores 5 elements of float as follow:

LA[] = {1.5, 1.2, 1.8, 1.6, 1.1};

Delete an element available at the third and fourth position of an array and print the output as follow:

Output:
LA[0] = 1.5
LA[1] = 1.2
LA[2] = 1.1

Exercise 7 - Search Operation

LA is an array where it stores 5 element of vowel character as follow:

LA[] = {'a', 'e', 'i', 'o', 'u'}; 

Search an element with a value of 'e' from the array and print the output as follow:

Output: 
Found character e at position 2

Exercise 8 - Search Operation

LA is a 2D array where it stores 6 element of integer number as follow:

LA[3][2] = {{1,2}, {3,4}, {5,6}};

Search an element in the 2D array with a value of 5 and print the output as follow:

Output: 
Found value 5 at position row 3 column 1

Exercise 9 - Update Operation

LA is an array where it store 10 elements of an integer as follow:

LA[] = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20};

Update an existing element from the array at index 4 with 100 and print the output as follow:

Output: 
LA[0] = 2
LA[1] = 4
LA[2] = 6
LA[3] = 8
LA[4] = 100
LA[5] = 12
LA[6] = 14
LA[7] = 16
LA[8] = 18
LA[9] = 20

Exercise 10 - Update Operation

LA is a 2D array where it stores 6 element of integer number as follow:

LA[3][2] = {{1,2}, {3,4}, {5,6}};

Update an existing element from the array at row 3 column 2 with value 50 and print the output as follow:

Output: 
1 2
3 4
5 50

Fighting! ⭐

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages