Problems 1. Check If An Expression Is Balanced or Not
Problems 1. Check If An Expression Is Balanced or Not
Créer une structure de liste chainée qui contient une seule information de type
réel
2. Donner un algorithme qui permet d’ajouter au debut un nouvel élément à la liste
3. Donner un algorithme qui permet de supprimer au debut un élément à la liste
4. En supposant que la liste Tab est remplie, fournir un algorithme qui effectue la
recherche d’un élément dans la liste:
a. Dans le cas Tab non trié
b. Dans le cas Tab trié
c. Discuter de la complexité de chacun des deux cas précédents.
5. Fournir un algorithme qui effectue la suppression d’un élément de la liste :
a. Dans le cas Tab non trié
b. Dans le cas Tab trié
c. Discuter de la complexité de chacun des deux cas précédents.
Links :
https://kingrayhan.medium.com/500-data-structures-and-algorithms-practice-
problems-and-their-solutions-b45a83d803f0
https://www.techiedelight.com/linked-list-implementation-part-1/
http://cslibrary.stanford.edu/105/
Problems
For example,
{[{}{}]}[()], {{}{}}, []{}() are balanced expressions.
Hints
We can use a stack to solve this problem. The idea is to traverse the given
expression, and
Given a set of activities, along with the starting and finishing time of each activity,
find the maximum number of activities performed by a single person assuming that a
person can only work on a single activity at a time.
For example,
Hints
Let’s assume there exist n activities each being represented by a start time si and
finish time fj. Two activities i and j are said to be non-conflicting if si = fj or sj = fi.
We can solve this problem by being greedy. Using a greedy approach will always
result in an optimal solution to this problem. The idea is to initially sort the activities
in increasing order of their finish times and create a set S to store the selected
activities and initialize it with the first activity. Then from the second activity onward,
include the activity in the activities list if the activity’s start time is greater or equal to
the finish time of the last selected activity. Repeat this for each activity involved.