1

I'm bored

posted in Off Topic
Comments:
Threaded Linear
#1
froggy_lol

Ask me anything

#2
kamisavitar
0
Frags
+

what is time complexity to search an element in an RB Tree?

#3
froggy_lol
2
Frags
+

The time complexity of searching an element in a red-black (RB) tree is O(log n), where n is the number of nodes in the tree.

#4
NexusNomad
0
Frags
+

Consider 4 boxes, where each box contains 3 red balls and 2 blue balls. Assume that all 20 balls are distinct. In how many different ways can 10 balls be chosen from these 4 boxes so that from each box at least one red ball and one blue ball are chosen ?

#5
froggy_lol
0
Frags
+

To solve this problem, we can use a combinatorial approach. We'll break it down into cases:

Choose 1 red ball and 1 blue ball from each of the 4 boxes.
Choose 2 red balls and 1 blue ball from one box, and 1 red ball and 2 blue balls from each of the remaining 3 boxes.
Choose 1 red ball and 2 blue balls from one box, and 2 red balls and 1 blue ball from each of the remaining 3 boxes.
Let's calculate the number of ways for each case:

Choosing 1 red ball and 1 blue ball from each of the 4 boxes:
(
3
1
)
×
(
2
1
)
(
1
3

)×(
1
2

) ways from each box
Total ways =
(
3
1
)
×
(
2
1
)
(
1
3

)×(
1
2

)^4

Choosing 2 red balls and 1 blue ball from one box, and 1 red ball and 2 blue balls from each of the remaining 3 boxes:
(
3
2
)
×
(
2
1
)
(
2
3

)×(
1
2

) ways to choose from one box
(
3
1
)
×
(
2
2
)
(
1
3

)×(
2
2

) ways to choose from each of the remaining 3 boxes
Total ways =
(
3
2
)
×
(
2
1
)
×
(
3
1
)
×
(
2
2
)
(
2
3

)×(
1
2

)×(
1
3

)×(
2
2

)^4

Choosing 1 red ball and 2 blue balls from one box, and 2 red balls and 1 blue ball from each of the remaining 3 boxes:
(
3
1
)
×
(
2
2
)
(
1
3

)×(
2
2

) ways to choose from one box
(
3
2
)
×
(
2
1
)
(
2
3

)×(
1
2

) ways to choose from each of the remaining 3 boxes
Total ways =
(
3
1
)
×
(
2
2
)
×
(
3
2
)
×
(
2
1
)
(
1
3

)×(
2
2

)×(
2
3

)×(
1
2

)^4

Now, we sum up the total number of ways from each case to get the final answer. Let's calculate it.

Let's calculate the number of ways for each case:

Choosing 1 red ball and 1 blue ball from each of the 4 boxes:
(
3
1
)
(
1
3

) ways to choose 1 red ball from each box
(
2
1
)
(
1
2

) ways to choose 1 blue ball from each box
Total ways =
(
3
1
)
×
(
2
1
)
(
1
3

)×(
1
2

)^4

Choosing 2 red balls and 1 blue ball from one box, and 1 red ball and 2 blue balls from each of the remaining 3 boxes:
(
3
2
)
(
2
3

) ways to choose 2 red balls from one box
(
2
1
)
(
1
2

) ways to choose 1 blue ball from one box
(
3
1
)
(
1
3

) ways to choose 1 red ball from each of the remaining 3 boxes
(
2
2
)
(
2
2

) ways to choose 2 blue balls from each of the remaining 3 boxes
Total ways =
(
3
2
)
×
(
2
1
)
×
(
3
1
)
×
(
2
2
)
(
2
3

)×(
1
2

)×(
1
3

)×(
2
2

)^4

Choosing 1 red ball and 2 blue balls from one box, and 2 red balls and 1 blue ball from each of the remaining 3 boxes:
(
3
1
)
(
1
3

) ways to choose 1 red ball from one box
(
2
2
)
(
2
2

) ways to choose 2 blue balls from one box
(
3
2
)
(
2
3

) ways to choose 2 red balls from each of the remaining 3 boxes
(
2
1
)
(
1
2

) ways to choose 1 blue ball from each of the remaining 3 boxes
Total ways =
(
3
1
)
×
(
2
2
)
×
(
3
2
)
×
(
2
1
)
(
1
3

)×(
2
2

)×(
2
3

)×(
1
2

)^4

Now, let's calculate each of these expressions.

Let's first calculate the number of ways for each case:

Choosing 1 red ball and 1 blue ball from each of the 4 boxes:
(
3
1
)
(
1
3

) ways to choose 1 red ball from each box
(
2
1
)
(
1
2

) ways to choose 1 blue ball from each box
Total ways =
(
3
1
)
×
(
2
1
)
(
1
3

)×(
1
2

)^4

Choosing 2 red balls and 1 blue ball from one box, and 1 red ball and 2 blue balls from each of the remaining 3 boxes:
(
3
2
)
(
2
3

) ways to choose 2 red balls from one box
(
2
1
)
(
1
2

) ways to choose 1 blue ball from one box
(
3
1
)
(
1
3

) ways to choose 1 red ball from each of the remaining 3 boxes
(
2
2
)
(
2
2

) ways to choose 2 blue balls from each of the remaining 3 boxes
Total ways =
(
3
2
)
×
(
2
1
)
×
(
3
1
)
×
(
2
2
)
(
2
3

)×(
1
2

)×(
1
3

)×(
2
2

)^4

Choosing 1 red ball and 2 blue balls from one box, and 2 red balls and 1 blue ball from each of the remaining 3 boxes:
(
3
1
)
(
1
3

) ways to choose 1 red ball from one box
(
2
2
)
(
2
2

) ways to choose 2 blue balls from one box
(
3
2
)
(
2
3

) ways to choose 2 red balls from each of the remaining 3 boxes
(
2
1
)
(
1
2

) ways to choose 1 blue ball from each of the remaining 3 boxes
Total ways =
(
3
1
)
×
(
2
2
)
×
(
3
2
)
×
(
2
1
)
(
1
3

)×(
2
2

)×(
2
3

)×(
1
2

)^4

Now, let's calculate each of these expressions.

Let's start by calculating the number of ways for each case:

Choosing 1 red ball and 1 blue ball from each of the 4 boxes:
(
3
1
)
(
1
3

) ways to choose 1 red ball from each box
(
2
1
)
(
1
2

) ways to choose 1 blue ball from each box
Total ways =
(
3
1
)
×
(
2
1
)
(
1
3

)×(
1
2

)^4

Choosing 2 red balls and 1 blue ball from one box, and 1 red ball and 2 blue balls from each of the remaining 3 boxes:
(
3
2
)
(
2
3

) ways to choose 2 red balls from one box
(
2
1
)
(
1
2

) ways to choose 1 blue ball from one box
(
3
1
)
(
1
3

) ways to choose 1 red ball from each of the remaining 3 boxes
(
2
2
)
(
2
2

) ways to choose 2 blue balls from each of the remaining 3 boxes
Total ways =
(
3
2
)
×
(
2
1
)
×
(
3
1
)
×
(
2
2
)
(
2
3

)×(
1
2

)×(
1
3

)×(
2
2

)^4

Choosing 1 red ball and 2 blue balls from one box, and 2 red balls and 1 blue ball from each of the remaining 3 boxes:
(
3
1
)
(
1
3

) ways to choose 1 red ball from one box
(
2
2
)
(
2
2

) ways to choose 2 blue balls from one box
(
3
2
)
(
2
3

) ways to choose 2 red balls from each of the remaining 3 boxes
(
2
1
)
(
1
2

) ways to choose 1 blue ball from each of the remaining 3 boxes
Total ways =
(
3
1
)
×
(
2
2
)
×
(
3
2
)
×
(
2
1
)
(
1
3

)×(
2
2

)×(
2
3

)×(
1
2

)^4

Now, let's calculate each of these expressions.

Let's calculate the number of ways for each case:

Choosing 1 red ball and 1 blue ball from each of the 4 boxes:
(
3
1
)
(
1
3

) ways to choose 1 red ball from each box
(
2
1
)
(
1
2

) ways to choose 1 blue ball from each box
Total ways =
(
3
1
)
×
(
2
1
)
(
1
3

)×(
1
2

)^4

Choosing 2 red balls and 1 blue ball from one box, and 1 red ball and 2 blue balls from each of the remaining 3 boxes:
(
3
2
)
(
2
3

) ways to choose 2 red balls from one box
(
2
1
)
(
1
2

) ways to choose 1 blue ball from one box
(
3
1
)
(
1
3

) ways to choose 1 red ball from each of the remaining 3 boxes
(
2
2
)
(
2
2

) ways to choose 2 blue balls from each of the remaining 3 boxes
Total ways =
(
3
2
)
×
(
2
1
)
×
(
3
1
)
×
(
2
2
)
(
2
3

)×(
1
2

)×(
1
3

)×(
2
2

)^4

Choosing 1 red ball and 2 blue balls from one box, and 2 red balls and 1 blue ball from each of the remaining 3 boxes:
(
3
1
)
(
1
3

) ways to choose 1 red ball from one box
(
2
2
)
(
2
2

) ways to choose 2 blue balls from one box
(
3
2
)
(
2
3

) ways to choose 2 red balls from each of the remaining 3 boxes
(
2
1
)
(
1
2

) ways to choose 1 blue ball from each of the remaining 3 boxes

#8
NexusNomad
0
Frags
+

Allat
Just give me final answer

#9
anyth1ng
0
Frags
+

its obvious🙄🙄🙄

answer:

y0y

#10
froggy_lol
0
Frags
+

21816

#11
CRONO
0
Frags
+

To find the number of ways to choose 10 balls from the 4 boxes such that each box contributes at least one red ball and one blue ball, you can use a combinatorial approach.

Let's break down the problem:

From each box, you need to choose at least one red ball and one blue ball.
You have a total of 4 boxes, and each box contributes 2 types of balls (red and blue).
Now, let's consider the choices:

Choose 1 red ball from each of the 4 boxes:
(
3
1
)
×
(
3
1
)
×
(
3
1
)
×
(
3
1
)
(
1
3

)×(
1
3

)×(
1
3

)×(
1
3

)
Choose 1 blue ball from each of the 4 boxes:
(
2
1
)
×
(
2
1
)
×
(
2
1
)
×
(
2
1
)
(
1
2

)×(
1
2

)×(
1
2

)×(
1
2

)
Now, you need to choose 2 more balls from the remaining pool of 8 (4 boxes * 2 types):

Choose 2 balls from the remaining 8:
(
8
2
)
(
2
8

)
Now, multiply these choices to get the total number of ways:

Total ways
=
(
3
1
)
×
(
3
1
)
×
(
3
1
)
×
(
3
1
)
×
(
2
1
)
×
(
2
1
)
×
(
2
1
)
×
(
2
1
)
×
(
8
2
)
Total ways=(
1
3

)×(
1
3

)×(
1
3

)×(
1
3

)×(
1
2

)×(
1
2

)×(
1
2

)×(
1
2

)×(
2
8

)

Calculating each term individually:

Total ways
=
3
×
3
×
3
×
3
×
2
×
2
×
2
×
2
×
28
Total ways=3×3×3×3×2×2×2×2×28

Total ways
=
1458
×
28
Total ways=1458×28

Total ways
=
40824
Total ways=40824

Therefore, there are 40,824 different ways to choose 10 balls from the 4 boxes such that each box contributes at least one red ball and one blue ball.

#6
Charism
0
Frags
+

JEE de raha?

#7
NexusNomad
0
Frags
+

Nah I cleared it last year itself

  • Preview
  • Edit
› check that that your post follows the forum rules and guidelines or get formatting help
Sign up or log in to post a comment