# Week 19

## Source Code

```lua
-- define main function
function main()
    print("Main Function")
    local done = false
    local choice = nil
    print("Menu")
    print("E1 - Example 1")
    print("Q - Quit")
    io.write("Choice: ")
    choice = io.read()
    if choice == "E1" then
        -- create list1
        
        -- before
    
        -- Example 1 Function call

        -- After


    elseif choice == "E2" then
        -- Example 2 Function call


    elseif choice == "E3" then
        -- Example 3 Function call


    elseif choice == "E4" then
        -- Example 4 Function call


    elseif choice == "E5" then
        -- Example 5 Function call


    elseif choice == "E6" then
        -- Linear Search Function call
        

    elseif choice == "E7" then
        -- Binary Function call
        

    elseif choice == "Q" then
        done = true
    else
        print("Invalid Choice")
    end
end

-- define printList function


-- define Example 1 Function


-- define Example 2 Function


-- define Example 3 Function


-- define Example 4 Function


-- define Example 5 Function


-- define linearSearch Function


-- define binarySearch Function
function binarySearch(array, target)
    local low = 1
    local high = #array

    while low <= high do
        local mid = (low + high) // 2 -- midpoint
        local guess = array[mid]

        if guess == target then
            return mid -- target found
        elseif guess > target then
            high = mid - 1
        else
            low = mid + 1
        end
    end

    return -1
end

-- call to main function, do not delete!
main()

```

## w19problem1.lua

```lua
-- function definition
function problem1()

end

-- function definition
function main()
    -- function call

end

-- call to main function
main()
```

## w19problem2.lua

```lua
-- function definition
function problem2()

end

-- function definition
function main()
    -- function call

end

-- call to main function
main()
```

## w19problem3.lua

```lua
-- function definition
function problem3()

end

-- function definition
function main()
    -- function call

end

-- call to main function
main()
```

## w19problem4.lua

```lua
-- function definition
function problem4()

end

-- function definition
function main()
    -- function call

end

-- call to main function
main()
```

## w19problem5.lua

```lua
-- function definition
function problem5()

end

-- function definition
function main()
    -- function call

end

-- call to main function
main()
```

## w19problem6.lua

```lua
-- function definition
function problem6()

end

-- function definition
function main()
    -- function call

end

-- call to main function
main()
```

## w19problem7.lua

```lua
-- function definition
function problem7()

end

-- function definition
function main()
    -- function call

end

-- call to main function
main()
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.csprinciples.com/code/week-19.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
