Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Array Operations: Creating, Finding, Sorting, and Manipulating Arrays, Lecture notes of Computer Science

Ten basic array operations including creating an array of size 10 with user input, checking if an element exists in an array, finding minimum and maximum elements, reversing an array, sorting an array using a sorting algorithm, finding the kth largest and smallest numbers, determining the number of occurrences of a number in an array, sorting an array without using a sorting algorithm, and finding the range of an array. Each operation includes a hint and a sample input size.

What you will learn

  • How can I check if a number is present in an array?
  • How do I reverse an array?
  • How do I sort an array without using a sorting algorithm?
  • How can I determine the number of occurrences of a number in an array?
  • How do I move all negative elements to one side of the array?
  • What is the range of an array?

Typology: Lecture notes

2010/2011

Uploaded on 09/21/2021

sakshi-sharma-26
sakshi-sharma-26 🇮🇳

5 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Array%
Basic%Questions
:%
%%
1)%Create%an%Array%of%size%10%of%integers.%Take%input%from%the%user%for%these%
10%elements%and%print%the%entire%array%after%that.%
%
%
%
2)%Check%whether%n%is%present%in%an%array%of%size%m%or%not.%
Input%-%%n,m%(Input%number,%size%of%array)%
-%%%%%%%%%Take%input%n%elements%for%the%array%
Output%->%true/false%
%%%%%%%%% % [%Hint%:%-%Create%a%dynamic%array]%
%
%
%
%
pf3
pf4

Partial preview of the text

Download Array Operations: Creating, Finding, Sorting, and Manipulating Arrays and more Lecture notes Computer Science in PDF only on Docsity!

Array

Basic Questions :

  1. Create an Array of size 10 of integers. Take input from the user for these 10 elements and print the entire array after that.
  2. Check whether n is present in an array of size m or not. Input - n,m (Input number, size of array)
  • Take input n elements for the array Output - > true/false [ Hint : - Create a dynamic array]
  1. Find the minimum and maximum element in an array. [ Solution: https://www.geeksforgeeks.org/program-find-minimum-maximum-element-array/] Here in sample input : 5 is the size of array
  2. Write a program to reverse the array. [Hint: use indexes] Here , 5 is the size of array and then elements of arrays are input
  3. Write a program to sort the given array. [Hint: use any sorting algorithm i.e. https://www.geeksforgeeks.org/sorting-algorithms/] Here, 6 is the size of array and then the elements are input by the user
  1. Find the range of the array. Range means the difference between the maximum and minimum element in the array. here , 6 is the size of array followed by the input of elements Here , Range = 91-(-3) = 94
  2. Move all the negative elements to one side of the array. NOTE: You have to write the code for each question Such that, First you have to write the code to input the size of array Second input the elements also by the user And then perform the mentioned algorithm