0
0
Data Structures Theoryknowledge~10 mins

Sliding window technique in Data Structures Theory - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize the sliding window start index.

Data Structures Theory
start = [1]
Drag options to blanks, or click blank then click option'
ANone
B-1
C0
D1
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Starting the window at 1 instead of 0.
Using None or negative values as start index.
2fill in blank
medium

Complete the code to move the sliding window end index forward by one.

Data Structures Theory
end = [1] + 1
Drag options to blanks, or click blank then click option'
Astart
Bend
Cwindow_size
Dlength
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Adding 1 to start instead of end.
Using window_size or length incorrectly.
3fill in blank
hard

Fix the error in the code to shrink the sliding window from the left.

Data Structures Theory
start = [1] + 1
Drag options to blanks, or click blank then click option'
Astart
Bend
Cwindow_size
Dlength
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Increasing end instead of start.
Using window_size or length incorrectly.
4fill in blank
hard

Fill both blanks to create a sliding window dictionary comprehension that stores word lengths for words longer than 3 characters.

Data Structures Theory
{word: [1] for word in words if [2] > 3}
Drag options to blanks, or click blank then click option'
Alen(word)
Cword
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using word instead of len(word) for length.
Filtering by word instead of its length.
5fill in blank
hard

Fill all three blanks to create a sliding window dictionary comprehension that stores uppercase words and their lengths if length is greater than 4.

Data Structures Theory
{ [1]: [2] for word in words if [3] > 4 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
Dword
Attempts:
3 left
πŸ’‘ Hint
Common Mistakes
Using word instead of word.upper() as key.
Filtering by word instead of length.
Mixing up key and value positions.