Searching an Array for an Exact Match
+6
Lawrence
judedominguiano
airojames
Sean
Sean Monacillo
iramae
10 posters
Page 1 of 2 • 1, 2
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 .
Figure D
Figure D.1
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 MonacilloJourneyman
- Posts : 7
Join date : 2018-08-02
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
Sent from Topic'it App
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
- SeanExpert
- Posts : 16
Join date : 2018-08-02
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
- SeanExpert
- Posts : 16
Join date : 2018-08-02
Re: Searching an Array for an Exact Match
Fri Aug 03, 2018 5:51 pm
hmmm thank you po ma'am medjo nadagdagan napo Idea ko hehheiramae 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
Sent from Topic'it App
- airojamesExpert
- Posts : 14
Join date : 2018-08-03
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?
6 decision pa po dadaanan nya bago masabi ng program na hindi po valid yung input nyang item?
- airojamesExpert
- Posts : 14
Join date : 2018-08-03
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
yung tinutukoy ko po yung may value na madaming digtits ex. 517,367,737,110.00
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.
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
- airojamesExpert
- Posts : 14
Join date : 2018-08-03
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
Sent from Topic'it App
- airojamesExpert
- Posts : 14
Join date : 2018-08-03
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
Tulog tulog din po haha
Sent from Topic'it App
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
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
- judedominguianoExpert
- Posts : 10
Join date : 2018-08-08
Re: Searching an Array for an Exact Match
Wed Aug 08, 2018 8:52 am
Dadaan siya pero mabilis that's how computer works.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.
Re: Searching an Array for an Exact Match
Thu Aug 09, 2018 7:43 am
judedominguiano wrote:Dadaan siya pero mabilis that's how computer works.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.
Yeah thats the point for programming.
- LawrenceExpert
- Posts : 10
Join date : 2018-08-11
Re: Searching an Array for an Exact Match
Sat Aug 11, 2018 7:57 pm
pero pre pwede ka gumamit ng boolean expression sa decision para mas mapabilis yung program.airojames wrote:Medyo magulo po dito
6 decision pa po dadaanan nya bago masabi ng program na hindi po valid yung input nyang item?
- PoxExpert
- Posts : 10
Join date : 2018-08-11
Re: Searching an Array for an Exact Match
Sat Aug 11, 2018 8:20 pm
Lawrence wrote:pero pre pwede ka gumamit ng boolean expression sa decision para mas mapabilis yung program.airojames wrote:Medyo magulo po dito
6 decision pa po dadaanan nya bago masabi ng program na hindi po valid yung input nyang item?
Kaya nga papahirapan mo pa sarili mo kung papadaanin mo pa sya sa 6 decision na yun
Sent from Topic'it App
- PoxExpert
- Posts : 10
Join date : 2018-08-11
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
- PoxExpert
- Posts : 10
Join date : 2018-08-11
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
- PoxExpert
- Posts : 10
Join date : 2018-08-11
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
Sent from Topic'it App
- judedominguianoExpert
- Posts : 10
Join date : 2018-08-08
Re: Searching an Array for an Exact Match
Wed Aug 15, 2018 8:10 am
ma'am diba dapat sub < SIZE AND foundit = "N" ?
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
- Jung kookExpert
- Posts : 13
Join date : 2018-08-12
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
(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/
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
(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/
Kapag may negative, pwede ka gumawa ng another process for that. It depends on you if what action you will do.
- RheiExpert
- Posts : 10
Join date : 2018-08-16
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.
Page 1 of 2 • 1, 2
Permissions in this forum:
You cannot reply to topics in this forum