In: Computer Science
1. What is a regular expression? Write a regular expression that will detect “College” and “collegE”.
2. What is degree centrality? Create a graph of 4 vertices and compute the degree centrality of the vertices.
3. Compute internal and external community densities for a graph containing 6 nodes. You can create any graph of 6 nodes with at least 4 edges.
Solution:
Regular Expression:
A regular expression is a set or a sequence of characters that can be used to detect the presence of a pattern.
These are generally used by string search and find algorithms.
In some cases where the input validation is needed, the regular expressions can be used.
In order to validate email id, the regular expression can be used.
The regular expression used for detecting the strings College and collegE is as follows.
^[Cc]olleg[Ee]$
Explanation:
^ represent the start character. The string must start with character c or C.
$ represent the end of string. The string must end with E or e.
The characters present in the middle must occur after c or C and before e or E.
Note:
Please see that as per the guidelines, only single question can be
answered when multiple questions are present.
In case of multiple choice type questions, upto 4 can be answered. Thank you.
Please let me know in the comments section in case of any help needed.