Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Seating Students Have the function Seatingstudents {arr} read the array of integers stored in arr which will be in the following format: lit. r'I. r2.

image text in transcribedimage text in transcribedimage text in transcribed
Seating Students Have the function Seatingstudents {arr} read the array of integers stored in arr which will be in the following format: lit. r'I. r2. r3. ...] where K represents the number of desks in a classroom. and the rest ofthe integers in the array will be in sorted order and will represent the desks that are already occupied. All of the desks will be arranged in 2 columns] where desk #1 is at the top left. desk #2 is at the top right, desk #3 is below #1, desk #4 is below #2, etc. Vour program should return the number of ways 2 students can be seated next to each other. This means 1 student is on the left and 1 student on the right. or \"I student is directly above or below the other student. For example: if arr is [12, 2, 6, 7, 11] then this classrooms looks like the following picture: 1 2 3 4 5 6 7 8 9 10 11 12Based an above arrangement ef eeeupied desks. there are a total at a ways tp seat 2 new students next to each ether. The sambinatiens are: ['I. 3]. [3.4]. [3. 5]. [8. 10]. [9. 10]. [1 D. 12]. So far this input your program should return E. K will range from 2 ts 24 and will always be an even number. After K. the number of pesupied desks in the array can range from it to K. Examples Input: [6, 4] Output: 4 Input: [8, 1, 3] Output: 6

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Android 4 Application Development

Authors: Reto Meier

3rd Edition

1118223853, 9781118223857

More Books

Students also viewed these Programming questions