< Ace Coding /> ๐Ÿš€
337 subscribers
54 photos
2 videos
95 files
66 links
Welcome to Ace Coding! Join us for tips, tutorials, and insights on coding and software engineering. Stay updated with the latest content and elevate your programming skills!Let's learn and grow together in the world of software engineering!
Download Telegram
exam questions.pdf
6.5 KB
โœ… AASTU 2023 GC  COA MID EXAM

Computer organization and architecture Mid exam with correct answers

๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
โค1
Forwarded from GDG On Campus AASTU (๐š‹๐š’๐š›๐šž๐š” ๐š–)
โญ๏ธ Attention Students! Register Now for Google Developer Group Study Sessions! โญ๏ธ

Are you ready to kickstart your tech career or take your skills to the next level? ๐Ÿš€ Whether youโ€™re a complete beginner or a seasoned coder, we have a track thatโ€™s perfect for you to grow, learn, and build something amazing! ๐ŸŒฑ๐Ÿ‘จโ€๐Ÿ’ป

๐Ÿง‘โ€๐ŸŽ“ Available Tracks:


1. Data Structures & Algorithms (DSA)
Master problem-solving techniques and boost your coding skills with DSA! ๐Ÿ”๐Ÿงฉ

2. Backend Development (Django & Node.js)
Dive into backend development and build powerful server-side applications! โš™๏ธ๐Ÿ›ก

3. Mobile Development with Flutter
Create sleek, cross-platform mobile apps that users love! ๐Ÿ“ฑโšก๏ธ

4. Web Development with React
Learn the framework that powers some of the worldโ€™s best applications! ๐ŸŒŽโœจ

5. Beginners Track

No coding experience? No problem! Learn the essentials of HTML, CSS, and JavaScript from the ground up! ๐ŸŒฑ

๐Ÿ‘‰ Donโ€™t Waitโ€”Register Now!

Join a community of creators, builders, and innovators and be part of the future of tech! ๐ŸŒŽ๐Ÿš€
Please open Telegram to view this post
VIEW IN TELEGRAM
๐Ÿ’ปA2SV prep: Sliding window problem

๐ŸŸก 2024. Maximize the Confusion of an Exam

Straight forward solution
class Solution:
def maxConsecutiveAnswers(self, answerKey: str, k: int) -> int:
n = len(answerKey)
max_length = 0

flips = k
l, r = 0, 0
# F -> T
while r < n:
if answerKey[r] == 'F':
flips -= 1
if flips < 0:
if answerKey[l] == 'F':
flips += 1
l += 1

max_length = max(max_length, r - l + 1)
r += 1

flips = k
l, r = 0, 0
# T -> F
while r < n:
if answerKey[r] == 'T':
flips -= 1
if flips < 0:
if answerKey[l] == 'T':
flips += 1
l += 1

max_length = max(max_length, r - l + 1)
r += 1

return max_length


As you have noticed there are some repetions in the code so I have modularized it into one single function that can calculate the possible maximum length.

class Solution:
def maxConsecutiveAnswers(self, answerKey: str, k: int) -> int:

def calculateLength(ans: str):
flips = k
max_length = 0

n = len(answerKey)
l, r = 0, 0

while r < n:
if answerKey[r] == ans:
flips -= 1
if flips < 0:
if answerKey[l] == ans:
flips += 1
l += 1

max_length = max(max_length, r - l + 1)
r += 1

return max_length

return max(calculateLength('T'), calculateLength('F'))


https://leetcode.com/problems/maximize-the-confusion-of-an-exam/description/
๐Ÿ“ฃ A2SV Interview Format ๐Ÿ“ฃ

Get ready for an exciting and comprehensive interview process! Hereโ€™s what to expect:

๐Ÿ•’ Total Duration: 1 Hour 30 Minutes

๐Ÿ’Ž Behavioral Interview (First 45 Minutes)
This part of the interview will focus on your past experiences, skills, and motivations.
Be prepared to discuss situations where you demonstrated leadership, teamwork, and problem-solving abilities.
They might ask questions like:
โญ๏ธ Tell me about yourself.
โญ๏ธ What do you know about A2SV and why do you want to join us?
โญ๏ธ Describe a time when you had to step out of your comfort zone to achieve something.

๐Ÿ’Ž Technical Interview (Remaining 45 Minutes)
This segment will test your coding and problem-solving skills.
Youโ€™ll be given programming challenges to solve in real-time.
Much of this interview will utilize sharepad.io as the collaborative coding editor.
Example questions might include:
Write a function to solve a particular algorithm problem.
Explain your approach to solving a complex data structure challenge.

๐Ÿ”ง Preparation Tips:

๐Ÿ’Ž Practice Coding: Brush up on your data structures and algorithms. Websites like LeetCode and codeforce are great for practice.

๐Ÿ’Ž Stay Calm and Confident: Remember, theyโ€™re not just looking for the right answers but also how you approach problems and handle stress.


Prepare well and best of luck to everyone!๐Ÿงจ๐Ÿš€
โœ… Almost Identical question with the above ๐Ÿ‘†very easy if you did the above

๐Ÿ’ปA2SV prep: Sliding window problem
๐ŸŸก 1004. Max Consecutive Ones III

โณ2 min on the clock PR for me ๐Ÿ˜…

class Solution:
def longestOnes(self, nums: List[int], k: int) -> int:
max_length = 0
l = 0
for r in range(len(nums)):
if nums[r] == 0:
k -= 1
while k < 0:
if nums[l] == 0:
k += 1
l += 1

max_length = max(max_length, r - l + 1)

return max_length


๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ

https://leetcode.com/problems/max-consecutive-ones-iii/description/
๐Ÿ“กCOA - Computer Organization and Architecture

Hardwired vs. Microprogrammed (Softwired) Logic

โœ… The Teacher was stressing this topic (๐Ÿ’ฐlikely to come up on the exam)

Hardwired Logic:
Functionality is embedded directly into the hardware using fixed circuits. These systems are fast and efficient but lack flexibility, as changes require hardware redesign. This is common in specific-purpose computers, like appliances or embedded systems optimized for specific tasks (e.g., calculators).

Microprogrammed (Softwired) Logic:
Here, functionality is defined by software, making these systems flexible and adaptable but slightly slower due to software execution overhead. Softwired logic is a hallmark of general-purpose computers, like laptops or servers, which can handle multiple tasks by running different programs.

Takeaway:
Hardwired logic is best for specialized, high-speed tasks, while softwired logic is ideal for versatile, multi-functional systems.

๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
๐Ÿ’ป A2SV prep: Sliding window problem

โœ… The following questions should be done sequentially. Level 1 and Level 2

๐ŸŸข 3206. Alternating Groups I Easy
๐Ÿ”—Link: Click here!

python 
class Solution:
def numberOfAlternatingGroups(self, colors: List[int]) -> int:
count = 0
# check the end colors
if len(colors) > 2:
if colors[0] != colors[1] and colors[1] == colors[-1]:
count += 1
if colors[-2] != colors[-1] and colors[-2] == colors[0]:
count += 1

l, r = 0, 0
k = 3
for r in range(len(colors)):
if r - l + 1 == 3:
l += 1
if r < len(colors) - 1 and colors[l] == colors[r+1] and colors[l] != colors[r]:
count += 1

return count


๐Ÿ“— A more optimized version
class Solution:
def numberOfAlternatingGroups(self, colors: List[int]) -> int:
n = len(colors) # keep the orginal length for latter
count = 0

# extend the colors array to simulate a circular pattern
colors.extend(colors[:2])

for r in range(n):
if colors[r] == colors[r+2] and colors[r] != colors[r+1]:
count += 1

return count



๐ŸŸก 3208. Alternating Groups II ~ 1800 ( Hard medium )
๐Ÿ”— Link: Click here!

python 
class Solution:
def numberOfAlternatingGroups(self, colors: List[int], k: int) -> int:
count = 0

colors.extend(colors[:k-1]) # if k = 3 we add 2 numbers like the above question
print(colors)

L = 0
for R in range(1, len(colors)):

if colors[R] == colors[R-1]:
L = R
if R - L + 1 == k:
count += 1
L += 1

return count



๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
๐Ÿ’ป A2SV prep: Sliding window problem

๐ŸŸก 3191. Minimum Operations to Make Binary Array Elements Equal to One I
๐Ÿ”— Link: Click here

class Solution:
def minOperations(self, nums: List[int]) -> int:
n = len(nums)
count = L =0
for R in range(n - 2):
if nums[R] == 0:
nums[R] = 1 - nums[R]
nums[R + 1] = 1 - nums[R + 1]
nums[R + 2] = 1 - nums[R + 2]
count += 1

if nums[L] == 1: L+= 1

for i in range(len(nums)):
if nums[i] == 0:
return -1
return count


๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
๐Ÿ”ฅ Gear Up for Java Exam! QUIZ Time ๐Ÿ”ฅ

Get ready for a detailed and comprehensive Java prep with tricky questions.

๐Ÿ’ก Donโ€™t miss outโ€”share with friends and tackle it together! ๐Ÿš€

#javaexam #oopexam #oopquiz #javaquiz #oopmidexam #javamidexam

๐ŸŒŸ๐Ÿš€ @AceCoding Presents! ๐Ÿš€๐ŸŒŸ
Java supports operator overloading
Anonymous Quiz
65%
True
35%
False
Java provides automatic memory management using garbage collection.
Anonymous Quiz
90%
True
10%
False
What is the correct file extension for compiled Java files?
Anonymous Quiz
61%
a) .java
30%
b) .class
4%
c) .jar
4%
d) .exe
Which keyword is used to inherit a class in Java?
Anonymous Quiz
31%
a) extend
57%
b) extends
4%
c) implement
8%
d) inherits
What is the default value of a boolean in Java?
Anonymous Quiz
20%
a) true
63%
b) false
10%
c) null
8%
d) 0
Which package is imported by default in Java?
Anonymous Quiz
35%
a) java.util
38%
b) java.lang
5%