Attribution Non-Commercial (BY-NC)

54 views

Attribution Non-Commercial (BY-NC)

- 0x7=0 1x7=7 2 x 7 = 14 3 x 7
- Maths Olympiad
- Excel Formula s(1)
- APSC 160 (UBC)
- FontMetrics (Java Platform SE 7 )
- 2Q -MATH4-ADMU
- Week 8 Word Problems
- Main
- adding double digits
- Maths Chp01
- TCS - Model Questions Sets - All (1)
- bpj lesson 18
- lessen 18-2
- sol review checklist 2015
- 4.8real_nmbr_system
- Java Arrays
- Java.lang.Number
- Excel Reckoner
- Primitive Data Types
- Arrays

You are on page 1of 3

Question: An array is said to be hollow if it contains 3 or more zeros in the middle that

are preceded and followed by the same number of non-zero elements. Furthermore, all

the zeroes in the array must be in the middle of the array. Write a function

named isHollow that accepts an integer array and returns 1 if it is a hollow array,

otherwise it returns 0.

int isHollow(int[ ] a)

int isHollow(int a[ ], int len) where len is the number of elements in the array

Examples:

is

if the input array is Reason

hollow?

{1,2,0,0,0,3,4} yes 2 non-zeros precede and follow 3 zeros in the middle

{1,1,1,1,0,0,0,0,0,2,1,2,18} yes 4 non-zeros precede and follow the 5 zeros in the middle

{1, 2, 0, 0, 3, 4} no There are only 2 zeroes in the middle; at least 3 are required

The number of preceding non-zeros(2) is not equal to the

{1,2,0,0,0,3,4,5} no

number of following non-zeros(3)

The number of preceding non-zeros(3) is not equal to the

{3,8,3,0,0,0,3,3} no

number of following non-zeros(2)

{1,2,0,0,0,3,4,0} no Not all zeros are in the middle

{0,1,2,0,0,0,3,4} no Not all zeros are in the middle

The number of preceding non-zeros is 0 which equals the

{0,0,0} yes number of following non-zeros. And there are three zeros

"in the middle".

Hint: Write three loops. The first counts the number of preceding non-zeros. The

second counts the number of zeros in the middle. The third counts the number of

following non-zeros. Then analyze the results.

Question: Define a flipflop array to be one whose elements alternate between even

and odd values or vice versa. A flipflop array must have at least two elements. For

example {0, 3, 4, -7} and {1, 2, 3, 4} are flipflop arrays but {2, 2, 3, 4}, {1, 2, 3, 3, 4}

and {2} are not.

Write a function called isFlipFlop that returns 1 if its argument is a flipflop array,

otherwise it returns 0.

int isFlipFlop (int [ ] a)

int isFlipFlop (int a [ ], int len) where len is the number of elements in the array.

A rhino number is a prime number whose last digit is 9 and the next prime number

that follows it also ends with the digit 9. For example 139 is a rhino number because:

1. it is a prime

2. it ends in 9

3. The next prime number after it is 149 which also ends in 9. Note that 140, 141,

142, 143, 144, 145, 146, 147 and 148 are not prime so 149 is the next prime

number after 139.

returns 1 if it is a rhino number otherwise it return 0. So isRhinoNumber(139) would

return 1.

int isRhinoNumber(int n)

Number Reason why it is not a rhino number

6 It is not a prime

17 Although it is prime, its last digit is not 9

It is prime and the last digit is 9 but the next prime number is 23

19

which does not end with 9

199 The next prime number, 211, does not end with 9

You may assume that a function named isPrime exists that returns 1 if its argument is

a prime, otherwise it returns 0. In other words, you do not have to write this function,

you just have to call it

- 0x7=0 1x7=7 2 x 7 = 14 3 x 7Uploaded byhaolhu
- Maths OlympiadUploaded bySidharth Kumar
- Excel Formula s(1)Uploaded bySkulkarni104
- APSC 160 (UBC)Uploaded byJFOXX7777
- FontMetrics (Java Platform SE 7 )Uploaded bypcdproyecto
- 2Q -MATH4-ADMUUploaded byflower.power11233986
- Week 8 Word ProblemsUploaded bymandamoll99
- MainUploaded byJeremias Tays
- adding double digitsUploaded byapi-467694433
- Maths Chp01Uploaded byAnonymous VZREav
- TCS - Model Questions Sets - All (1)Uploaded bySumit Jha
- bpj lesson 18Uploaded byapi-307095237
- lessen 18-2Uploaded byapi-307094458
- sol review checklist 2015Uploaded byapi-272374768
- 4.8real_nmbr_systemUploaded byAkia Alexis
- Java ArraysUploaded byPL Villaflores Iglesia
- Java.lang.NumberUploaded byKeyur Golani
- Excel ReckonerUploaded byBharat Heda
- Primitive Data TypesUploaded byBella Artist
- ArraysUploaded byPuneet Atwal
- bpj lesson 18Uploaded byapi-308024418
- bpj lesson 18Uploaded byapi-307096342
- bpj lesson 18Uploaded byapi-307093760
- bpj lesson 18Uploaded byapi-307093549
- bpj lesson 18Uploaded byapi-307556335
- bpj lesson 18Uploaded byapi-307093369
- bpj lesson 18Uploaded byapi-307093352
- bpj lesson 18Uploaded byapi-307093335
- bpj lesson 18Uploaded byapi-307093682
- Chpt2Uploaded bythanhtungka_91

- leaveencashment-100721093319-phpapp01Uploaded bymonikasingh019
- Enrique Gaspar- El Anacronópete- EnglishUploaded byMarcel Hagen
- Net Ip UbiquitiUploaded bycleciooliveira
- budget projectUploaded byapi-283546611
- Plant CoordinationUploaded byArif Ullah
- Air Sampling and Industrial HygieneUploaded byGenilson Almeida
- f14 TomcatUploaded bymam73
- Mitsibushi FGC15_33NUploaded byAB
- Harsh Verma Types of Services - People,Possesion,Mental Stimulus,Information Processing Harsh VermaUploaded byPoonam Jewrani
- cf2daypacketUploaded byMus Mualim
- Semester 1 FEB2016 Final Examination Timetable (Listing)Uploaded byMadison Haze
- 8 House _ BIG _ ArchDailyUploaded byWeldri Berto Ocmafiyon
- eq_unit20_ergonomics.pdfUploaded byPraveena Nair Sivasankaran
- Skripsi Rifa'atul Mahmudah "Analisis Usaha Jamur Tiram"Uploaded byRifa'atul Mahmudah Al Masir
- A Survey On Designing Of Turbo Encoder & Turbo DecoderUploaded byIJAFRC
- Osteogenesis Imperfecta Overview[1]Uploaded byMariclaudia Vásquez Chacón
- Tax LLC Seminar Gene Pringle 2Uploaded byLuke
- PNB vs AtendidoUploaded byMJ Decolongon
- Anthanassios Liakopoulos - GRNET- IPv6Uploaded byzarobiza
- Ventilation for Buildings - Calculation Methods for the Determination of Air Flow Rates in Buildings Including InfiltrationUploaded byAntonio Lebrun
- BSU.pdf Boise State University catalogUploaded bydustinnieffenegger
- 05 Microtunneling Machines 22Uploaded byMadalina Nitu
- Small Antibody Mimetics ComprisingUploaded bygalebinjo
- Group Accounting PoliciesUploaded bymapati66
- 7 Practical Ideas for Prayer Before ClassUploaded byFrancis Carmelle Tiu Duero
- The effect of heat treatment on mechanical properties and corrosion behavior of AISI420 martensitic stainless steelUploaded byanon_506964735
- Datasheet CAM5525Uploaded byej.wang
- Shear Bond Strength of Orthodontic BracketsUploaded byArijAftab
- Eval Study Ead TeachersUploaded byfreches
- Project on WTOUploaded byYash Shah