Docsity

It's good document for beginners, Study notes of Computer science

Partial preview of the text

Download It's good document for beginners and more Study notes Computer science in PDF only on Docsity!

Arrays

Arrays An array 13 A Inca dala Structure Val Stores a fixed S126 Sequinls af clement of Me same data Hype In cralia y Ovs Memory locations. Each clement con be aleessod directly usin Us index position, Arrays U tng ne index position “ Array inc Ary {ol = Area [|= Array Elements. = i yf u Array Cz] =¥ Herayl s J 27) { array [2] 4|| 8 || 12] 16] 18 | [) 1 2 3 4 5 +— Array Indexes Figure | Figure show Wow bow Ne dements are Moved IM an 1- dhaycnsiaa array Indexing an Arey U olde USG in d6X position ly access We elements M Wie) d + lade xing OF glymcdls tm an Areay Start wilh 0 msde oF | ) U «Gut covating Ve number of Olement slevk with 1 mslad of/ zerd Element First Index {at Index 8) ool 2 3 4 S§ 6 F | 9-— Indices | ee) Array Length is 10 ————+ Figuré 2 wAs sad te Sth in Fiaure 2 indexi na shart at zela Arrays Page 1 rigure ¢ As you cn $06 ot Fgura indexing Start al zerg A *Areay loath equal ihe avabte of element in Shard uly Arty tg th = last udex position +] ola Fyvee a last sadex position 15 4 Adding q gy will gu you to whih ts Areay Lem Uh dimensions of he Array U A areey Gn bg a stagle dineastond ike a t-0 array Vor MU dime ns ional like an a-0 ard 0 arty AMd $0 On. 1D Array 2D Array G23) 2/3) tas ai3| (112/3E8 3 2/3} Bese 1/2[3F Figure 3 uw tis Course wo will Fros on 10 and ag Array aa an laure 20 Artay. a- di monsional Array U We un vigvalize a two -diwtnstondl. Atiay QS pnl- dime dsional Het olacked vet cally Formby a bnble with ‘wm’ vows aM a columns, J the tow dimber fatgts From o bo (m-1). + mL luna aumber ~ reyes From 0 €o Cn-1), Arrays Page 2 Accessing Elements in 2-o, mensiend| Areey V U An olomal um a-dimedsional artay 1s cot ssed usida fy indexes And Column indetes Side array Subscript optrator CJ. arr_ nal Cilfs]o tis ts how yav ALILSS A ¢ a-J nitey Arey Aamt fer ay quien problems you nutd bo know How to fiad Maxim value in an Arey Exangle « given are és 3h zy} Algorithm 1. Initialize a variable maxVal with value arr[O]. 2. Traverse through the whole array. During traversal: 1. If maxVal is less than the current value of array update the value of maxVal. 2. Else continue. 3. Exit the loop after whole traversal and Print res which denotes the maximum value in array. yy | dave giver you an Alyaci Th ty fy Follow if and write a fil ¢ pry lag * How by everse crag dement mc? de 1. aalh thal. cae wh Moa. Llausale? Arrays Page 4 * HOW Fg Abver b6 meng vioMontT ING ! ~ How fa cAlovlale sum oF Arty Elyacals ’ * How to Sort an Areey in Ascending /Jesccadg order 7 iy and solve also Me last Meroe Questo as Lill Share solutions with you Ihe neat Glass Usb hg ares | lave qivit you above as exameld by eylye Mest Questions After rudiay Mag wales try and do yas} 79 TTA qvesitwa lo fesd yer wader nding