Something You Want to Know About Arrays
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Searching an Array for an Exact Match

+6
Lawrence
judedominguiano
airojames
Sean
Sean Monacillo
iramae
10 posters
Go down
iramae
iramae
Admin
Posts : 139
Join date : 2018-07-19
Age : 24
https://iramaecomp.forumotion.com

Searching an Array for an Exact Match Empty Searching an Array for an Exact Match

Tue Jul 31, 2018 1:03 pm

On the past lesson, you learned how to use arrays in a specific number or item. Unfortunately, real life doesn’t always happen in small integers. Sometimes you don’t have a variable that conveniently holds an array position; sometimes you have to search through an array to find a value you need.

For example, assume that the item numbers from which a customer can choose are three-digit numbers, but perhaps they are not consecutively numbered 001 through 999. For example, let’s say that you offer six items: 106, 108, 307, 405, 457, and 688, as shown in the shaded VALID_ITEMS array declaration in Figure D. The array is declared as constant because the item numbers do not change during program execution. When you search through a list from one end to the other, you are performing a linear search .




Searching an Array for an Exact Match Figure15

Figure D



Searching an Array for an Exact Match Figure16

Figure D.1



Searching an Array for an Exact Match Figure17

Figure D.2





To determine if an ordered item number is valid, you could use a series of six decisions to compare the number to each of the six allowed values. However, the superior approach shown in Figure D.2 is to create an array that holds the list of valid item numbers and then to search through the array for an exact match to the ordered item. If you search through the entire array without finding a match for the item the customer ordered, it means the ordered item number is not valid.
Sean Monacillo
Sean Monacillo
Journeyman
Posts : 7
Join date : 2018-08-02

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Thu Aug 02, 2018 9:15 pm
Ma'an yung pag flag po ba pwede po ba na lagpas ng dalawa ?

Sent from Topic'it App
iramae
iramae
Admin
Posts : 139
Join date : 2018-07-19
Age : 24
https://iramaecomp.forumotion.com

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Thu Aug 02, 2018 11:08 pm
Sean Monacillo wrote:Ma'an yung pag flag po ba pwede po ba na lagpas ng dalawa ?

Sent from Topic'it App

Yes sean, possible yung flag na more than 2 kase yung flag naman mag iindjcate kung nameet mo na yung hinahanap mo or hindi, perp common na flag lang is either Y or N
Sean
Sean
Expert
Posts : 16
Join date : 2018-08-02

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Fri Aug 03, 2018 5:50 pm
Sean Monacillo wrote:Ma'an yung pag flag po ba pwede po ba na lagpas ng dalawa ?

...

Sent from Topic'it App
Sean
Sean
Expert
Posts : 16
Join date : 2018-08-02

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Fri Aug 03, 2018 5:51 pm
iramae wrote:
Sean Monacillo wrote:Ma'an yung pag flag po ba pwede po ba na lagpas ng dalawa ?


Yes sean, possible yung flag na more than 2 kase yung flag naman mag iindjcate kung nameet mo na yung hinahanap mo or hindi, perp common na flag lang is either Y or N
hmmm thank you po ma'am 😊 medjo nadagdagan napo Idea ko hehhe

Sent from Topic'it App
avatar
airojames
Expert
Posts : 14
Join date : 2018-08-03

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Fri Aug 03, 2018 10:39 pm
Medyo magulo po dito
6 decision pa po dadaanan nya bago masabi ng program na hindi po valid yung input nyang item?
avatar
airojames
Expert
Posts : 14
Join date : 2018-08-03

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Fri Aug 03, 2018 10:42 pm
Hindi po ba pwede na dalawang desicion na lang tulad nung example nya na kung saan ginamitan ng AND and OR logic?
yung tinutukoy ko po yung may value na madaming digtits ex. 517,367,737,110.00
iramae
iramae
Admin
Posts : 139
Join date : 2018-07-19
Age : 24
https://iramaecomp.forumotion.com

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Fri Aug 03, 2018 11:27 pm
airojames wrote:Medyo magulo po dito
6 decision pa po dadaanan nya bago masabi ng program na hindi po valid yung input nyang item?

ichecheck niya simula unang element ng array mo hanggang sa end ng array element mo bago ka makaalis sa part na yun kase sa process na yun, dun pa lang nagaganap yung searching. So titingnan niya if equal bh yung hinahanap mo sa declared array element mo.,, kung wala bale counted aiya as bad item.
iramae
iramae
Admin
Posts : 139
Join date : 2018-07-19
Age : 24
https://iramaecomp.forumotion.com

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Fri Aug 03, 2018 11:27 pm
airojames wrote:Hindi po ba pwede na dalawang desicion na lang tulad nung example nya na kung saan ginamitan ng AND and OR logic?
yung tinutukoy ko po yung may value na madaming digtits ex. 517,367,737,110.00


Yes, mas easy yung mangyayare kung gagamitan mo siya ng AND logic
avatar
airojames
Expert
Posts : 14
Join date : 2018-08-03

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Fri Aug 03, 2018 11:30 pm
Ahh pero pwede po na mabawasan yung condition?

Sent from Topic'it App
avatar
airojames
Expert
Posts : 14
Join date : 2018-08-03

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Fri Aug 03, 2018 11:31 pm
Salamat po mam sensya na po medyo parehas lang yung tanong ko doon sa isa
Tulog tulog din po haha

Sent from Topic'it App
iramae
iramae
Admin
Posts : 139
Join date : 2018-07-19
Age : 24
https://iramaecomp.forumotion.com

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Sat Aug 04, 2018 7:12 pm
airojames wrote:Salamat po mam sensya na po medyo parehas lang yung tanong ko doon sa isa
Tulog tulog din po haha

Sent from Topic'it App

hahaha okay lang, atleast nalilinawan na pakonti konti Smile
iramae
iramae
Admin
Posts : 139
Join date : 2018-07-19
Age : 24
https://iramaecomp.forumotion.com

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Sat Aug 04, 2018 7:13 pm
airojames wrote:Ahh pero pwede po na mabawasan yung condition?

Sent from Topic'it App

yes, pwede siyang mabawasan
judedominguiano
judedominguiano
Expert
Posts : 10
Join date : 2018-08-08

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Wed Aug 08, 2018 8:52 am
iramae wrote:
airojames wrote:Medyo magulo po dito
6 decision pa po dadaanan nya bago masabi ng program na hindi po valid yung input nyang item?

ichecheck niya simula unang element ng array mo hanggang sa end ng array element mo bago ka makaalis sa part na yun kase sa process na yun, dun pa lang nagaganap yung searching. So titingnan niya if equal bh yung hinahanap mo sa declared array element mo.,, kung wala bale counted aiya as bad item.
Dadaan siya pero mabilis that's how computer works.
iramae
iramae
Admin
Posts : 139
Join date : 2018-07-19
Age : 24
https://iramaecomp.forumotion.com

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Thu Aug 09, 2018 7:43 am
judedominguiano wrote:
iramae wrote:
airojames wrote:Medyo magulo po dito
6 decision pa po dadaanan nya bago masabi ng program na hindi po valid yung input nyang item?

ichecheck niya simula unang element ng array mo hanggang sa end ng array element mo bago ka makaalis sa part na yun kase sa process na yun, dun pa lang nagaganap yung searching. So titingnan niya if equal bh yung hinahanap mo sa declared array element mo.,, kung wala bale counted aiya as bad item.
Dadaan siya pero mabilis that's how computer works.

Yeah thats the point for programming.
Lawrence
Lawrence
Expert
Posts : 10
Join date : 2018-08-11

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Sat Aug 11, 2018 7:57 pm
airojames wrote:Medyo magulo po dito
6 decision pa po dadaanan nya bago masabi ng program na hindi po valid yung input nyang item?
pero pre pwede ka gumamit ng boolean expression sa decision para mas mapabilis yung program.
Pox
Pox
Expert
Posts : 10
Join date : 2018-08-11

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Sat Aug 11, 2018 8:20 pm
Lawrence wrote:
airojames wrote:Medyo magulo po dito
6 decision pa po dadaanan nya bago masabi ng program na hindi po valid yung input nyang item?
pero pre pwede ka gumamit ng boolean expression sa decision para mas mapabilis yung program.


Kaya nga papahirapan mo pa sarili mo kung papadaanin mo pa sya sa 6 decision na yun

Sent from Topic'it App
Pox
Pox
Expert
Posts : 10
Join date : 2018-08-11

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Sat Aug 11, 2018 8:22 pm
iramae wrote:
airojames wrote:Hindi po ba pwede na dalawang desicion na lang tulad nung example nya na kung saan ginamitan ng AND and OR logic?
yung tinutukoy ko po yung may value na madaming digtits ex. 517,367,737,110.00


Yes, mas easy yung mangyayare kung gagamitan mo siya ng AND logic


Yes pwedeng pwede papahirapan mo pa sarili mo kung itatype mo pa yan kaya nga may programing pre

Sent from Topic'it App
Pox
Pox
Expert
Posts : 10
Join date : 2018-08-11

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Sat Aug 11, 2018 8:23 pm
iramae wrote:
airojames wrote:Ahh pero pwede po na mabawasan yung condition?


yes, pwede siyang mabawasan

Oo pre pwede mabawasan pwede din.nman madagdag nasa sayo kung saan ka madadalian

Sent from Topic'it App
Pox
Pox
Expert
Posts : 10
Join date : 2018-08-11

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Sat Aug 11, 2018 8:25 pm
Sean wrote:
Sean Monacillo wrote:Ma'an yung pag flag po ba pwede po ba na lagpas ng dalawa ?

...


Pwede.nman siguro pre pero dba yung flag is indicator so pwede sya pero parang pinahaba mo lang yung process
Pagkakaintindi ko kasi gagamit ka nun para mas mapadali yung program mo Smile

Sent from Topic'it App
judedominguiano
judedominguiano
Expert
Posts : 10
Join date : 2018-08-08

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Wed Aug 15, 2018 8:10 am
ma'am diba dapat sub < SIZE AND foundit = "N" ?
iramae
iramae
Admin
Posts : 139
Join date : 2018-07-19
Age : 24
https://iramaecomp.forumotion.com

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Thu Aug 16, 2018 7:16 am
judedominguiano wrote:ma'am diba dapat sub < SIZE AND foundit = "N" ?

Yes sir para mas easy yung searching process Smile
avatar
Jung kook
Expert
Posts : 13
Join date : 2018-08-12

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Thu Aug 16, 2018 10:35 am
iramae wrote:
judedominguiano wrote:ma'am diba dapat sub < SIZE AND foundit = "N" ?

Yes sir para mas easy yung searching process Smile

(Pasale po hehe)

Sa condition po ni sir na ito, kapag true "Go to process to find item", pero kapag false, "Proceed to state if Item found or not? Then input another item to be searched?"

Pero pwede po ibahin yung statement ng condition para mag iba din po yung flow ng dalawa output nya?
Meaning hindi lang isa yung pwedeng gawin mong condition, may iba pang functional na condition.
Kasi nga may positive tsaka negative minded (Ewan ko lang kung pwede i-connect 'to)

/tumitig sa kawalan/
/'di ko talaga alam sinasabi ko/
lol!
iramae
iramae
Admin
Posts : 139
Join date : 2018-07-19
Age : 24
https://iramaecomp.forumotion.com

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Thu Aug 16, 2018 10:37 am
Jung kook wrote:
iramae wrote:
judedominguiano wrote:ma'am diba dapat sub < SIZE AND foundit = "N" ?

Yes sir para mas easy yung searching process Smile

(Pasale po hehe)

Sa condition po ni sir na ito, kapag true "Go to process to find item", pero kapag false, "Proceed to state if Item found or not? Then input another item to be searched?"

Pero pwede po ibahin yung statement ng condition para mag iba din po yung flow ng dalawa output nya?
Meaning hindi lang isa yung pwedeng gawin mong condition, may iba pang functional na condition.
Kasi nga may positive tsaka negative minded (Ewan ko lang kung pwede i-connect 'to)

/tumitig sa kawalan/
/'di ko talaga alam sinasabi ko/
lol!

Kapag may negative, pwede ka gumawa ng another process for that. It depends on you if what action you will do.
avatar
Rhei
Expert
Posts : 10
Join date : 2018-08-16

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Thu Aug 16, 2018 10:46 am
Sean Monacillo wrote:Ma'an yung pag flag po ba pwede po ba na lagpas ng dalawa ?

Sent from Topic'it App

ang alam ko Christopher pwede. Rolling Eyes Rolling Eyes
Sponsored content

Searching an Array for an Exact Match Empty Re: Searching an Array for an Exact Match

Back to top
Permissions in this forum:
You cannot reply to topics in this forum